[23052] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5273 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 25 21:05:54 2003

Date: Fri, 25 Jul 2003 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 25 Jul 2003     Volume: 10 Number: 5273

Today's topics:
    Re: Called as method or subroutine? <mgjv@tradingpost.com.au>
    Re: Data::Dumper vs perl -d <wksmith@optonline.net>
    Re: delete directory files from a list.  Help Please <DieSpammersDie-no-spam@antigone.cotse.net>
    Re: delete directory files from a list.  Help Please <mbudash@sonic.net>
    Re: delete directory files from a list.  Help Please <DieSpammersDie-no-spam@antigone.cotse.net>
    Re: delete directory files from a list.  Help Please (Tad McClellan)
    Re: delete directory files from a list.  Help Please <admin@asarian-host.net>
    Re: extract list from webpage (plb)
        Is there a clean way to export all constants from a mod <stevea@wrq.com>
    Re: Is there a clean way to export all constants from a (Jay Tilton)
        Killing IE via win32::ole ?? (C. Martin)
    Re: Looking for  Perl school <michael.p.broida@boeing.com>
        mysql load data infile error from inside a perl program <res03jc6@verizon.net>
    Re: need help-how to parse references (susan)
    Re: Newbie: Problems with a CPAN installation <pkent77tea@yahoo.com.tea>
        Simple site index (reggie)
    Re: Stumped by formatting - newbie plea <pkent77tea@yahoo.com.tea>
    Re: Tracking Number (Jeff Mott)
    Re: use of shift exists? <dha@panix.com>
    Re: use of shift exists? <krahnj@acm.org>
    Re: UTF-8 module <pkent77tea@yahoo.com.tea>
    Re: UTF-8 module <pkent77tea@yahoo.com.tea>
    Re: XML or home-grown format? <jaspax@u.washington.edu>
    Re: XML or home-grown format? <iambrenNOSPAM@sympatico.ca>
    Re: XML or home-grown format? (MegaZone)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 26 Jul 2003 08:26:35 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Called as method or subroutine?
Message-Id: <slrnbi3bkr.rlm.mgjv@martien.heliotrope.home>

On 24 Jul 2003 06:21:58 GMT,
	Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Martien Verbruggen:
> 
>> On Wed, 23 Jul 2003 21:51:23 -0500,
>> 	Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
>>> 
>>> ed <coo_t2-NO-LIKE-SPAM@yahoo.com> wrote in 
>>> news:gk7uhvstvnnct0e73big7muhujl3h7jte9@4ax.com:
>>> 
>>>> Hi is there a way to make a sub/method compatible with 
>>>> the two following calling methods?
>>>> 
>>>> 1.  MyClass::mySub();
>>>> 2.  MyClass->mySub();

[snip]

>>> Well, you could check the first argument and see if it's equal to 
>>> __PACKAGE__.  But that's not a good solution, because it breaks 
>>> inheritance.
>> 
>> The notation MyClass::mySub() is not subject to inheritance in any
>> way. In other words, the above two calls cannot be equivalent, because
>> of Perl's magical treatment of that arrow. If you use that arrow, Perl
>> will search through @ISA. If you don't, then it won't.
> 
> Which, as far as I understand, was Eric's point.

The point that I was trying to make is that with a call like
MyClass::mySub() it is not even really possible to talk about
inheritance, since it's not a method call, but rather a regular
subroutine call, and therefore never subject to Perl's inheritance
mechanisms.  You do need the arrow for that. 

If Eric was indeed saying the same thing, then I apologise for
misreading what he said. The only thing I read in his post was that
using a hardcoded package name in a method breaks inheritance, because
you'll always be working in the __PACKAGE__ class, as opposed to the
class that was actually passed via the arrow, in calls like
Class->method();

Martien
-- 
                        | 
Martien Verbruggen      | Useful Statistic: 75% of the people make up
                        | 3/4 of the population.
                        | 


------------------------------

Date: Fri, 25 Jul 2003 22:34:22 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Data::Dumper vs perl -d
Message-Id: <OfiUa.145734$ye5.25585162@news4.srv.hcvlny.cv.net>


"Bill Smith" <wksmith@optonline.net> wrote in message
news:NmzTa.98495$ye5.17561926@news4.srv.hcvlny.cv.net...
> I have noticed that many of the frequent posters recommend
Data::Dumper
> for debugging data structure and reference problems.  I have always
used
> the "x" command in the perl debugger.
>
> The debugger offers several advantages.  The original script does not
> have to be temporarily changed.  The dump can be limited to critical
> loop iterations.  Alternate syntax can often be tested in the
debugging
> session.
>
> What advantages of the module approach am I overlooking?
>


Thanks all for pointing out all the special cases.  I have not done CGI
or time critical work in over a year.  How easy it is to forget.  I must
remember Randal's suggestion for saving test data which may be hard
(impossible?) to reproduce.

I like the perl debugger and will continue to use it for most of my
debugging tasks.  I feel that most beginners would benefit from learning
a few debugger commands early in their Perl education.

Thanks again,
Bill




------------------------------

Date: Fri, 25 Jul 2003 16:38:04 -0400 (EDT)
From: "DieSpammersDie" <DieSpammersDie-no-spam@antigone.cotse.net>
Subject: Re: delete directory files from a list.  Help Please
Message-Id: <YW50aWdvbmU=.c73a024b0bd0031b4a02e7db26d72084@1059165484.cotse.net>

John W. Krahn wrote:

> DieSpammersDie wrote:
> > 
> > Here is my problem.  I want to delete the files contained in a directory
> > from a list contained in a file.  Here is an example:
> > 
> > The input file is a regular text file in the following format (call it
> > myfile.txt);
> > 
> > item1
> > item2
> > item3
> > item4
> > ...
> > 
> > What I want to do is look in a directory and delete any file in the
> > directory that contains any item on the list.  For example, lets say the
> > contents of the directory looks like this:
> > 
> > 07/24/2003  01:27 AM             3,812 heresanitem1
> > 07/24/2003  10:42 PM           912,126 heretoitem2
> > 07/14/2003  12:19 AM               234 item3ishere
> > 06/12/2003  10:25 PM            34,049 leavemealone
> > 06/12/2003  10:25 PM            16,683 leavemealonetoo
> > 07/22/2003  11:36 PM             1,825 yupitem4yup
> > ...
> > 
> > I would like to read each line of the file from "myfile.txt" [getline() I
> > suppose] and then delete the files that have ANY MATCHING information from
> > the input file.  So if the input file has "item1" it will delete the file
> > "heresanitem1" as well as "alsoitem1aswell" from the directory.  So when I
> > run the script the sample directory above will look like this:
> > 
> > 06/12/2003  10:25 PM            34,049 leavemealone
> > 06/12/2003  10:25 PM            16,683 leavemealonetoo
> > ...
> > 
> > This problem has been tough for me.  I have read everything I can get my
> > hands on concerning unlink but I cannot get this problem solved.  Any help
> > appreciated.
>
> my $file = 'myfile.txt';
> my $dir  = '/home/DieSpammersDie/something';
>
> open my $fh, $file or die "Cannot open $file: $!";
>
> my $files = join ' ', map "$dir/*$_*", map split, <$fh>;
>
> unlink or warn "Cannot unlink $_: $!" for <$files>;

Rrghh!  I can see the logic, but this does not work either.  I have
administrator access to the directory so that's not the problem.  It's
killing me that such a simple problem is evading me.  Any other ideas?












































------------------------------

Date: Fri, 25 Jul 2003 20:48:42 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: delete directory files from a list.  Help Please
Message-Id: <mbudash-ED741D.13484325072003@typhoon.sonic.net>

In article 
<YW50aWdvbmU=.c73a024b0bd0031b4a02e7db26d72084@1059165484.cotse.net>,
 "DieSpammersDie" <DieSpammersDie-no-spam@antigone.cotse.net> wrote:

> John W. Krahn wrote:
> 
> > DieSpammersDie wrote:
> > > 
> > > Here is my problem.  I want to delete the files contained in a directory
> > > from a list contained in a file.  Here is an example:
> > > 
> > > The input file is a regular text file in the following format (call it
> > > myfile.txt);
> > > 
> > > item1
> > > item2
> > > item3
> > > item4
> > > ...
> > > 
> > > What I want to do is look in a directory and delete any file in the
> > > directory that contains any item on the list.  For example, lets say the
> > > contents of the directory looks like this:
> > > 
> > > 07/24/2003  01:27 AM             3,812 heresanitem1
> > > 07/24/2003  10:42 PM           912,126 heretoitem2
> > > 07/14/2003  12:19 AM               234 item3ishere
> > > 06/12/2003  10:25 PM            34,049 leavemealone
> > > 06/12/2003  10:25 PM            16,683 leavemealonetoo
> > > 07/22/2003  11:36 PM             1,825 yupitem4yup
> > > ...
> > > 
> > > I would like to read each line of the file from "myfile.txt" [getline() I
> > > suppose] and then delete the files that have ANY MATCHING information from
> > > the input file.  So if the input file has "item1" it will delete the file
> > > "heresanitem1" as well as "alsoitem1aswell" from the directory.  So when I
> > > run the script the sample directory above will look like this:
> > > 
> > > 06/12/2003  10:25 PM            34,049 leavemealone
> > > 06/12/2003  10:25 PM            16,683 leavemealonetoo
> > > ...
> > > 
> > > This problem has been tough for me.  I have read everything I can get my
> > > hands on concerning unlink but I cannot get this problem solved.  Any help
> > > appreciated.
> >
> > my $file = 'myfile.txt';
> > my $dir  = '/home/DieSpammersDie/something';
> >
> > open my $fh, $file or die "Cannot open $file: $!";
> >
> > my $files = join ' ', map "$dir/*$_*", map split, <$fh>;
> >
> > unlink or warn "Cannot unlink $_: $!" for <$files>;
> 
> Rrghh!  I can see the logic, but this does not work either.  I have
> administrator access to the directory so that's not the problem.  It's
> killing me that such a simple problem is evading me.  Any other ideas?

what the heck does "not work" mean? are you getting an error message? we 
need more than just "not work"!!
-- 
Michael Budash


------------------------------

Date: Fri, 25 Jul 2003 17:11:15 -0400 (EDT)
From: "DieSpammersDie" <DieSpammersDie-no-spam@antigone.cotse.net>
Subject: Re: delete directory files from a list.  Help Please
Message-Id: <YW50aWdvbmU=.8a93426a30b3112b496c41941dc7027c@1059167475.cotse.net>

Michael Budash wrote:

> In article 
> <YW50aWdvbmU=.c73a024b0bd0031b4a02e7db26d72084@1059165484.cotse.net>,
>  "DieSpammersDie" <DieSpammersDie-no-spam@antigone.cotse.net> wrote:
>
> > John W. Krahn wrote:
> > 
> > > DieSpammersDie wrote:
> > > > 
> > > > Here is my problem.  I want to delete the files contained in a directory
> > > > from a list contained in a file.  Here is an example:
> > > > 
> > > > The input file is a regular text file in the following format (call it
> > > > myfile.txt);
> > > > 
> > > > item1
> > > > item2
> > > > item3
> > > > item4
> > > > ...
> > > > 
> > > > What I want to do is look in a directory and delete any file in the
> > > > directory that contains any item on the list.  For example, lets say the
> > > > contents of the directory looks like this:
> > > > 
> > > > 07/24/2003  01:27 AM             3,812 heresanitem1
> > > > 07/24/2003  10:42 PM           912,126 heretoitem2
> > > > 07/14/2003  12:19 AM               234 item3ishere
> > > > 06/12/2003  10:25 PM            34,049 leavemealone
> > > > 06/12/2003  10:25 PM            16,683 leavemealonetoo
> > > > 07/22/2003  11:36 PM             1,825 yupitem4yup
> > > > ...
> > > > 
> > > > I would like to read each line of the file from "myfile.txt"
[getline() I
> > > > suppose] and then delete the files that have ANY MATCHING
information from
> > > > the input file.  So if the input file has "item1" it will delete the
file
> > > > "heresanitem1" as well as "alsoitem1aswell" from the directory.  So
when I
> > > > run the script the sample directory above will look like this:
> > > > 
> > > > 06/12/2003  10:25 PM            34,049 leavemealone
> > > > 06/12/2003  10:25 PM            16,683 leavemealonetoo
> > > > ...
> > > > 
> > > > This problem has been tough for me.  I have read everything I can get my
> > > > hands on concerning unlink but I cannot get this problem solved. 
Any help
> > > > appreciated.
> > >
> > > my $file = 'myfile.txt';
> > > my $dir  = '/home/DieSpammersDie/something';
> > >
> > > open my $fh, $file or die "Cannot open $file: $!";
> > >
> > > my $files = join ' ', map "$dir/*$_*", map split, <$fh>;
> > >
> > > unlink or warn "Cannot unlink $_: $!" for <$files>;
> > 
> > Rrghh!  I can see the logic, but this does not work either.  I have
> > administrator access to the directory so that's not the problem.  It's
> > killing me that such a simple problem is evading me.  Any other ideas?
>
> what the heck does "not work" mean? are you getting an error message? we 
> need more than just "not work"!!

Good point.  No, I don't get a message.  The program runs, but the files are
not deleted.  The files are still in the directory.  No messages or
anything.  I am going to add some error checking comments to direct the
ouput to a log file so I can see exactly what is happening.  Basically, the
program runs but does not delete the files from the filelist.  It's killing me.


















































------------------------------

Date: Fri, 25 Jul 2003 16:25:58 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: delete directory files from a list.  Help Please
Message-Id: <slrnbi3836.bov.tadmc@magna.augustmail.com>

Michael Budash <mbudash@sonic.net> wrote:
> In article 
><YW50aWdvbmU=.c73a024b0bd0031b4a02e7db26d72084@1059165484.cotse.net>,
>  "DieSpammersDie" <DieSpammersDie-no-spam@antigone.cotse.net> wrote:


[snip 50 lines of quoted text]


>> this does not work either.

> we 
> need more than just "not work"!!


And we need less than 50 quoted lines for a 2 line comment that
makes reference to half of 1 quoted line.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 26 Jul 2003 01:10:03 +0200
From: "Mark" <admin@asarian-host.net>
Subject: Re: delete directory files from a list.  Help Please
Message-Id: <fVydncvY3v1hJbyiXTWJhg@giganews.com>

"DieSpammersDie" <DieSpammersDie-no-spam@antigone.cotse.net> wrote in
message
news:YW50aWdvbmU=.c73a024b0bd0031b4a02e7db26d72084@1059165484.cotse.net...

> > > I would like to read each line of the file from "myfile.txt"
> > > [getline() I suppose] and then delete the files that have
> > > ANY MATCHING information from the input file.

[snip]

> > > This problem has been tough for me. I have read everything I can
> > > get my hands on concerning unlink but I cannot get this problem
> > > solved. Any help appreciated.
> >
> > my $file = 'myfile.txt';
> > my $dir  = '/home/DieSpammersDie/something';
> >
> > open my $fh, $file or die "Cannot open $file: $!";
> >
> > my $files = join ' ', map "$dir/*$_*", map split, <$fh>;
> >
> > unlink or warn "Cannot unlink $_: $!" for <$files>;
>
> Rrghh!  I can see the logic, but this does not work either.


Geez, guys, this is not higher math, you know. :)

open (NONOS, '/temp/myfile.txt') || exit 1;
chomp (@files = <NONOS>);
close (NONOS);
unlink <"/home/DieSpammersDie/something/"*$_*> foreach (@files);

Good luck with it.

- Mark




------------------------------

Date: 25 Jul 2003 12:55:01 -0700
From: plb@linuxmail.org (plb)
Subject: Re: extract list from webpage
Message-Id: <37aad647.0307251155.2d9eec9f@posting.google.com>

Bob Walton <bwalton@rochester.rr.com> wrote in message news:<3F209D14.3020802@rochester.rr.com>...
> plb wrote:
> 
> ...
> > I have a webpage setup that displays all 'active' vhosts that run on
> > my webserver.  This page is generated in ASP.  I would like to write a
> > perl script that takes the list of 'active' vhosts and writes them to
> > a text file.  Then I would like to compare this list to the wwwroot
> > directory on the webserver so I can delete any vhosts that are not in
> > use.  There is about a 300-400 difference between the webpage and
> > wwwroot directory.
> > 
> > Ideally I would like the script to:
> > 1) compile a list of active vhosts
> > 2) compare this list to the "wwwroot" directory
> > 3) delete any directory that is not on the list of active vhosts
> ...
> 
> 
> > plb
> 
> 
> Modules are your friend.  You may
> 
>     use LWP::Simple;
> 
> to get() your web page.  It is very simple:
> 
>     use LWP::Simple;
>     use warnings;
>     use strict;
>     my $webpage=get('http://some.server.com/some/path...');
> 
> Then you'll need to parse the HTML to retrieve the info you want:
> 
>     use HTML::Parser;
> 
> might help with that.  Warning:  Parsing HTML is much harder than it 
> looks at first glance -- that's why HTML::Parser is there.  Good luck.


Okay, I've been playing around with this for a while.  

The webpage I'm trying to access requires a username and password to
login.  I tried using some code like this:

my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET =>
'http://webadmin.foo.com/admin/VhostListSelect.asp');
$req->authorization_basic('username', 'password');
print $ua->request($req)->as_string;

However, that doesn't seem to work.  I run the sript and I get this:

P:\>perl vhosts.pl
HTTP/1.1 200 OK
Cache-Control: private
Connection: Keep-Alive
Date: Fri, 25 Jul 2003 19:37:10 GMT
Server: Microsoft-IIS/5.0
Content-Length: 169
Content-Type: text/html
Client-Date: Fri, 25 Jul 2003 19:37:11 GMT
Client-Peer: 10.50.11.151:80
Set-Cookie: ASPSESSIONIDGGGGGBRY=GFHCEJJCMFDBMCBIHNCPDBJL; path=/

<HTML>
<BODY>
        <CENTER><B><FONT FACE = "Arial" SIZE = "3">Access
Violation<br>You do no
t have access to this functionality.</FONT></B></CENTER>
</BODY>
</HTML>


I've looked at using HTML::Parser, and it's pretty gross...at least
for someone who isn't very good with Perl.

What I was thinking I could do is this - Save the results from the ASP
page to an HTML file.  Open that file, parse it with some sort of
regexp to get all the vhosts and dump that info into and array. 
Create an array with all the info from the wwwroot directory, compare
the two using a hash and that's should do it.  Does that sound
reasonable or is there any easier way.

I'm a little lost with all this.  

Thanks for all the help,
plb


------------------------------

Date: Sat, 26 Jul 2003 00:11:15 GMT
From: Steve Allan <stevea@wrq.com>
Subject: Is there a clean way to export all constants from a module?
Message-Id: <ud6fykuzh.fsf@wrq.com>


I'm creating a module for the sole purpose of defining constants to be
shared among several Perl scripts.  I'm looking for a way to simplify
getting all the constant names into the @EXPORT_OK array, so I don't
end up with this:

@EXPORT_OK = qw(CURRENTCHANGE BLDNUM STAGEROOTDIR ...);

because I can envision that list becoming large, and everytime I
define a new constant I have to remember to add it to the list.


Here's what I've tried:

Since the 'constant' pragma will accept a hash reference, I thought I
could define a hash, pass it's reference to constant and it's keys to
EXPORT_OK: 


my %build_properties = (
                        CURRENTCHANGE => 'currentChange',
                        BLDNUM => 'buildNumber',
                        STAGEROOTDIR   => 'stageRootDir',
                        WEBREPORTDIR   => 'webReportDir',
                       );

use constant \%build_properties;
@EXPORT_OK = (keys %build_properties);

That produces this error from the calling script:

Undefined subroutine &Constants::CURRENTCHANGE called ...

Changing the export to this:
@EXPORT_OK = qw(CURRENTCHANGE BLDNUM WEBREPORTDIR STAGEROOTDIR);

produced the same error.

The conventional way 

@EXPORT_OK = qw(CURRENTCHANGE BLDNUM WEBREPORTDIR STAGEROOTDIR);
use constant {
               CURRENTCHANGE  => 'currentChange',
               BLDNUM         => 'buildNumber',
               STAGEROOTDIR   => 'stageRootDir',
               WEBREPORTDIR   => 'webReportDir',
            };

works, so all seems fine with the calling script.  The problem *seems*
to be that

use constant \%build_properties

is not having the desired effect.

So, my questions are

1. Is there something wrong with 'use constant \%hash' ?

2. Is what I'm attempting to do bad Perl style?

3. If not 2, is there a preferred way to do this?
 

Thanks.

-- 
-- Steve


------------------------------

Date: Sat, 26 Jul 2003 00:48:11 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Is there a clean way to export all constants from a module?
Message-Id: <3f21ceb7.4370182@news.erols.com>

Steve Allan <stevea@wrq.com> wrote:

: Since the 'constant' pragma will accept a hash reference, I thought I
: could define a hash, pass it's reference to constant and it's keys to
: EXPORT_OK: 

That will work perfectly.

The hangup is whether the hash really is defined before
you "use constant ...".

: my %build_properties = (
:                         CURRENTCHANGE => 'currentChange',
:                         BLDNUM => 'buildNumber',
:                         STAGEROOTDIR   => 'stageRootDir',
:                         WEBREPORTDIR   => 'webReportDir',
:                        );
: 
: use constant \%build_properties;
: @EXPORT_OK = (keys %build_properties);

The assignment to %build_properties happens at run-time, but
"use constant \%build_properties;" happens at compile time.  
Put the assignment in a BEGIN{} block so it too happens during
compilation.

    my %build_properties;
    BEGIN{
        %build_properties = (
            CURRENTCHANGE => 'currentChange',
            BLDNUM => 'buildNumber',
            STAGEROOTDIR   => 'stageRootDir',
            WEBREPORTDIR   => 'webReportDir',
        );
    }
    use constant \%build_properties;
    @EXPORT_OK = (keys %build_properties);



------------------------------

Date: 25 Jul 2003 15:54:10 -0700
From: icebeing1@dslextreme.com (C. Martin)
Subject: Killing IE via win32::ole ??
Message-Id: <2e873c65.0307251454.2507b5f2@posting.google.com>

Hi,

I found this little code snippet while trying to figure out
how to bring up Internet Explorer with Perl:

+++++++++++
use Win32::OLE;
use strict;
use Time::HiRes;

my $browser = Win32::OLE->new('InternetExplorer.Application') or die "Aiee \n";

$browser->Navigate('http://www.gellyfish.com',1,'_BLANK');
+++++++

According to the docs, the 'Quit()' method should kill the browser I just
created, so this statement should work...

$browser->Quit();

I have IE 6.0 installed

Any ideas what's going on here?  Thanks, Charles


------------------------------

Date: Fri, 25 Jul 2003 18:08:20 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Looking for  Perl school
Message-Id: <3F217214.D67662EF@boeing.com>

Gerald Newton wrote:
> 
> I am looking for an onsite Perl school of 4 to 5 weeks.  This school would
> be for computer literate people who have previous programming experience,
> but are not professional programmers.  The school would have about 4 hours
> in class and a daily workshop where students would use their own laptops or
> school machines to practice with an instructor on hand.  The cost would be
> about $3 to $5 thousand not including board and room.  Does anyone know of
> such a program?

	Look at "ed2go.com".  You can see a list of courses there,
	but you can't sign up there.  You'll find a list of schools
	(community colleges, high schools, etc) who offer the courses
	(and collect money and give certificates) for them.  Go to
	the website for one of those schools to sign up.

	I took two Perl courses (and 7-8 other courses) from them
	through the local community college.  Pretty good courses,
	not too expensive ($59 or $69 for 6 weeks of online lessons).

		Mike


------------------------------

Date: Fri, 25 Jul 2003 22:30:00 GMT
From: "Balldrew J. Bag" <res03jc6@verizon.net>
Subject: mysql load data infile error from inside a perl program
Message-Id: <IbiUa.1646$FP5.1071@nwrddc02.gnilink.net>

This is my first attempt at writing something with Perl, so this is 
beyond a newbie question.

I'm both creating a table and trying to use the load data infile command 
from within a perl program.  All the permissions are set right and it 
actually does create the table and load the data, but it gives the 
following error and dies:

DBD::mysql::st execute failed: Access denied for user: 
'hightone@localhost' (Using password: YES) at 
/usr/lib/perl5/site_perl/5.6.0/i386-linux/Mysql.pm line 172.
count: Mysql::Statement=HASH(0x8246d4c)

That second line is me trying to output a variable called count's 
contents.  It should be an integer since this is what I'm doing:

$count = $db->query("select count(notes) from $noteList");

The fact that it prints something weird might be a clue.



------------------------------

Date: 25 Jul 2003 17:36:27 -0700
From: anzhenli@hotmail.com (susan)
Subject: Re: need help-how to parse references
Message-Id: <d1b124d8.0307251636.6fd2d6a2@posting.google.com>

Hello friends,

I am sorry I didn't provide enough information about the input. Here
is the example of my text file for the references:

REFERENCES
Alberts, B., Bray, D., and Lewis, J., Molecular Biology of the
Cell,2nd edition, Garland Publishing, New York,1989.
Van Holde.,Chromatic, Springer-Verlag, New York, 1989.
Bauer, W. R., Crick, F.H.C, and White, J. H., Supercoiled DNA,
Sci.Am.243, 100-125(1980).
Zhuang,X.,Ha,T.,Kim,H.D.,Cartner,T.m, Lebeit,S., and Chi,
S.,Fluorescence Quen-
ching: A tool for Single-Molecule Protein-Folding Study,
Natl.Acad.Sci.19,14,41-
64(2000).

I wrote: if (($Line =~/^[A-Z](.*)\d{4}(\))*\.$/)and ($Line =~/(\.,)/))
             { print "$Line\n"}
This will keep all the references having a single line. But I don't
know how to tell the computer to consider from "Alberts..." to "1989."
is only one citation. Further more, I want to separate the
inforamtion, output should look like:

1st author 2nd author Article_Name     Journal_or_BookName   
Alberts,B  Bray,D                     Molecular Biology of the Cell
Van Holde                              Chromatic
Bauer,W.R  Crick,F.H.C  Supercoiled DNA Sci.Am.

I plan to parse the 1st author, article name and jouranl name first
since they provide basic information. The final goal is try to parse
all the information.

Thanks for your advice.

Susan


tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbi2j8o.ahs.tadmc@magna.augustmail.com>...
> susan <anzhenli@hotmail.com> wrote:
> 
> 
> >
 I am practicing to parse a list of different
> > references. 
> 
> 
> If you show us several good examples of your data, we would
> probably be able to help you.
> 
> But you didn't, so we can't.
> 
> Have you seen the Posting Guidelines that are posted here frequently?
> 
> 
> > for example, the result I assume looks like:
>                ^^^^^^^^^^
>                ^^^^^^^^^^
> > author     article name    journal name or book name  volume#...year
> > Alison Balter              Access 2000 development              1999
> 
> 


> So that is the output you want from your program?
> 
> What does the input look like?
> 
> We cannot parse data that we know nothing about.
> 
> If that _is_ meant to be your input, then why must you "assume"
> what it looks like?
> 
> We must know the input with great precision if we are to devise
> a way to process it. "Assuming" what the input looks like will
> not result in an answer that is useable in real life.
> 
> 
> > I feel it is hard to find a regular expression to separate them. 
> 
> 
> Maybe you do not need a regular expression to separate them.
> 
> Maybe you could use some other approach...
> 
> 
> > Does
> > anyone advise me where I can find more inforamtion?
> 
> 
> ... but without knowing what you have, and how you want to
> transform it, we cannot advise one way or the other.
> 
> 
> Your post does not contain the information we need to answer your question.
> 
> Show use some example input. (one record is not good enough)
> 
> Show use some desired output (for that same data).
> 
> Tell (and show) us anything you know about the format of the input data:
> 
>    Can fields be "missing" or "empty"? How can you tell when they are?
>    Do the fields always line up in columns?
>    Is there some separator between each column?
> 
> If you can do something like that, then we would have a really
> good chance of being able to help you with your problem.


------------------------------

Date: Sat, 26 Jul 2003 00:39:22 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Newbie: Problems with a CPAN installation
Message-Id: <pkent77tea-F968CF.00392226072003@usenet.plus.net>

In article <5b829932.0307250052.49f5267a@posting.google.com>,
 francescomoi@europe.com (Francesco Moi) wrote:

> I'm trying to install 'LWP:Simple' module on my Linux machine.
> 
> # perl -MCPAN -e shell
> cpan> install LWP:Simple
> Going to read /root/.cpan/sources/modules/03modlist.data.gz
> Warning: Cannot install LWP:Simple, don't know what it is.

The module is actually called 'LWP::Simple' - download the whole 
distribution from:
http://search.cpan.org/author/GAAS/libwww-perl-5.69/

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


------------------------------

Date: 25 Jul 2003 15:49:06 -0700
From: reggie@reggieband.com (reggie)
Subject: Simple site index
Message-Id: <5117aba8.0307251449.231d818b@posting.google.com>

I am looking for help on choosing Perl modules for the following task:

Create an index of all html files on a site
  file - <title>

where 'file' is the directory+filename and '<title>' is the text
between the opening and closing HTML title tags.

I do not have access to the files system so I must go through HTTP.

I've rolled my own in the past, but this is for a client and I
wouldn't mind being pointed towards any modules that will help me best
ensure the task is thurough and complete.

I am looking at LWP::Simple, HTML::Parser, HTML::SimpleLinkExtor but I
am concerned at my own 'local link' routines (to ensure my code
follows <all but only> local links).  Any suggestions there?

Any advice would be appreciated.

reggie.


------------------------------

Date: Sat, 26 Jul 2003 00:53:06 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Stumped by formatting - newbie plea
Message-Id: <pkent77tea-14E4CD.00530626072003@usenet.plus.net>

In article <10876b94.0307240716.75c2442d@posting.google.com>,
 peterstokes@operamail.com (Peter Stokes) wrote:

> I'm trying to use a list, created from an array, to build a dropdown
> list in a web page form.
> 
> I start with a flatfile database, pipe delimited. The first field is
> the county, then the name, then other info. The dropdown list is to be
> of the counties.
> 
> I've got:
> open (INFILE, "db1.dat");
> while (<INFILE>) {
> 	@things = split /\|/;
> 	@counties = splice(@things,0,1);
> 
> This is fine, it generates my list, but of course it has duplicates in
> it. So to get rid of the duplicates I've got:
>     	@counties = grep( ( ($h{$_}++ < 1) || 0 ), @counties ); 
> Which does indeed get rid of the duplicates. 


Personally I often us a hash for this kind of de-duplicating task:

# example code...
foreach(@list_of_things) {
   $hash{$_} = 1;
}
foreach(sort keys %hash) {
   print "$_\n";
}

You may want to alter the sorting method if the things come out in an 
order that isn't right for you - that's easy to do.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


------------------------------

Date: 25 Jul 2003 16:50:07 -0700
From: mjeff1@twcny.rr.com (Jeff Mott)
Subject: Re: Tracking Number
Message-Id: <970676ed.0307251550.95d09b1@posting.google.com>

> It has really nothing to do with Perl at all,

I know. I had already said that, and I apologize. If you know of an
appropriate group, please let me know. I couldn't find one.

> but it turns out someone
> has already done a lot of this work. Go to search.cpan.org, and look
> for modules with Fedex and UPS in the name.

I already had. I found none that had a method for testing the validity
of each's respective tracking number. If you see one I did not, please
let me know.


------------------------------

Date: Fri, 25 Jul 2003 18:07:21 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: use of shift exists?
Message-Id: <slrnbi2sep.9l6.dha@panix2.panix.com>

In article <3F213C6A.28B8BA6C@xbn.nl>, David Bouman wrote:
> Mental Patient 0057 wrote:
> 
>> this moves one item over
>> $a = shift @rray;
>> 
>> is there a way to move three at a time?
> 
> Yes, use splice. A perldoc -f splice will explain it.

Or, if you want to keep your array intact, an array slice:
	($a, $b, $c) = @array[0..2];
	($d, $e, $f) = @array[3..5];

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Looking at the cake is like looking at the future.  Until you taste
it, what do you really know?  And, of course, by then, it's much too
late.    - Merlin, Excalibur


------------------------------

Date: Fri, 25 Jul 2003 18:08:16 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: use of shift exists?
Message-Id: <3F217256.460B72AC@acm.org>

Mental Patient 0057 wrote:
> 
> this moves one item over
> $a = shift @rray;
> 
> is there a way to move three at a time?
> ($a, $b, $c) = shift 3things @rray?

( $a, $b, $c ) = splice @rray, 0, 3;

> ($d, $e, $f, $g) = shift nowShift4Things @rray?

( $d, $e, $f, $g ) = splice @rray, 0, 4;

perldoc -f splice


John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Sat, 26 Jul 2003 01:09:30 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: UTF-8 module
Message-Id: <pkent77tea-C694D6.01093026072003@usenet.plus.net>

In article <Pine.LNX.4.53.0307251212390.21819@lxplus082.cern.ch>,
 "Alan J. Flavell" <flavell@mail.cern.ch> wrote:

> On Fri, Jul 25, Bob Walton inscribed on the eternal scroll:
> 
> > Jerry Maguire wrote:
> >
> > > Is there any module to encode a URL into UTF-8 format?
> 
> I assumed this was a question about encoding per RFC2718,
> http://www.ietf.org/rfc/rfc2718.txt

 ...as did I :-) ...

> Presumably what's needed is that every character whose ord() value is
> above 127 decimal needs to be subjected to some kind of unpack() or
> sprintf to yield the relevant number of %HH%HH... encoded ASCII
> strings.  Not forgetting, of course, to encode the so-called "unsafe"

The way I understood the RFC is this:

Take the original string, which can be in any form - 32-bit wide 
characters, EBCDIC, anything... and turn it into a UTF-8 string. This 
means that low-half code points will be represented in a single byte, 
but high-half (or beyond) characters will be represented as 2 or more 
bytes. Then go through the string doing the %HH escaping of every octet 
that requires escaping.

In my limited experiments (e.g. submitting an HTML form where I'd typed 
in some text with accented chars) IE6 will create a URL like:

http://example.com/cgi-bin/t.pl?spanish=se%C0%A2or%20manuel

you see how the 'n-tilde' character has been turned into its UTF8 
representation of _2_ bytes (ok I made the numbers up but it's somethign 
like that).

The problem I can forsee tripping people up is when you're encoding a 
character into a 2+ octet representation and one octet happens to be 
equal to a 'special' character, e.g. an '='. You can't simply escape 
_all_ the '=' in a URL because that'd trash the query string. I reckon 
what you have to do is what I often do: encode the keys and the values 
in the query string separately, and then join them together with '=' and 
';' characters. The same principle goes for other parts of the URL.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


------------------------------

Date: Sat, 26 Jul 2003 01:16:06 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: UTF-8 module
Message-Id: <pkent77tea-55CD77.01160626072003@usenet.plus.net>

In article <Pine.LNX.4.53.0307251212390.21819@lxplus082.cern.ch>,
 "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> Presumably what's needed is that every character whose ord() value is
> above 127 decimal needs to be subjected to some kind of unpack() or
> sprintf to yield the relevant number of %HH%HH... encoded ASCII
<snip>

Another thing I should point out is this code in CGI/Util.pm:


sub unescape {
 ...
  $todecode =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
    defined($1)? chr hex($1) : utf8_chr(hex($2))/ge;
 ...
(from http://search.cpan.org/src/JHI/perl-5.8.0/lib/CGI/Util.pm )

This implies to me that escapes of the form:

name=%u2112;age=23

will be accepted by CGI.pm and decoded as utf-8 2-octet sequences. I 
can't find this documented anywhere though, after a brief search.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


------------------------------

Date: Fri, 25 Jul 2003 14:16:04 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: XML or home-grown format?
Message-Id: <Pine.A41.4.56.0307251400220.109400@dante09.u.washington.edu>

I've added comp.text.xml to the cross-posting for this, since it's
probably more concerned with XML than anything else at this point. So far,
we've been discussing whether it's worth the trouble to move a custom file
format for the perl module Lingua::Phonology over to XML. I pointed out an
original example line like:

> >d    +anterior -distributed voice

Which would have to become:

> >In XML, this might have to be as verbose as:
> >
> ><symbol label="d`">
> >    <feature name="anterior" value="+" \>
> >    <feature name="distributed" value="-" \>
> >    <feature name="voice" \>
> ></symbol>

To which MegaZone suggested the shorter version:

> <symbol label="d" anterior="+" distributed="-" voice="+" />
>
> Something like that is just as valid in XML,

My response:

The example you gave is *well-formed* XML, which is different from *valid*
XML. The problem is that your example could never be valid XML, because
the attributes needed to define a given <symbol> cannot be known ahead of
time in the module. Rather, the list of feature names is given in a
separate <featureset></featureset> section.

True, one could make the featureset declaration into a DTD, but that would
require the users of my module to write their own DTD's, which is too much
work for them. I'd rather leave the validation of features against the
featureset to the application--which I'm also writing, so it's not much of
a problem.

I could go your way, but it would require all XML files parsed by my
module to run in standalone mode, and would prevent writing any DTD that
could validate all such files.

> Using XPath you can find the element based on one attribute and get
> the value of another - as in this:
> ---
> use strict;
> use warnings;
> use XML::LibXML 1.0053;
>
> my $xmlFile;
> my $parser = XML::LibXML->new();
>
> open (XMLCONF, "<./pcCurrencyTable.xml") ||
>     die "Can't open table: $!";
> while (<XMLCONF>) {
>     $xmlFile .= $_;
> }
> close (XMLCONF);
>
> my $dom = $parser->parse_string($xmlFile);
> $xpath = "//CurrencyTable/CurrencyShift[\@number='840']/\@name";
> print( ($dom->findnodes($xpath))[0]->textContent() . "\n");
>
> ----
>
> That prints "USD".

Something like this could provide an elegant way for the Lingua::Phonology
module to do checking that a given file doesn't contain errors (i.e. that
all attributes or feature names given for a <symbol> match some feature
declared in the <featureset> section. Once I've decided on my format, I'll
have to consider exactly how to do this.


--
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog

Jesus asked them, "Who do you say that I am?"

And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."

And Jesus said, "What?"


------------------------------

Date: Fri, 25 Jul 2003 18:41:55 -0400
From: Bren <iambrenNOSPAM@sympatico.ca>
Subject: Re: XML or home-grown format?
Message-Id: <dgc3ivgpor2buvh1gtopjuu022ulb86mt8@4ax.com>

On Fri, 25 Jul 2003 14:16:04 -0700, JS Bangs <jaspax@u.washington.edu>
wrote:

>> print( ($dom->findnodes($xpath))[0]->textContent() . "\n");
>>
>> ----
>>
>> That prints "USD".

Actually, that would print "USD
"

;-)





-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


------------------------------

Date: 25 Jul 2003 23:48:48 GMT
From: usenet@megazone.org (MegaZone)
Subject: Re: XML or home-grown format?
Message-Id: <megazone.1059176927@sidehack.sat.gweep.net>

Bren <iambrenNOSPAM@sympatico.ca> shaped the electrons to say:
>Actually, that would print "USD
>"

Yes.  Point. :-)

I actually changed my mind when doing my production code which I'd
written the test file as prep for and used the ->getAttribute() method
since I could first do -hasAttribute() in an if clause and else set it
to some default value, etc.

More than one way. ;-)

-MZ, CISSP #3762, RHCE #806199299900541
-- 
<URL:mailto:megazone@megazone.org> Gweep, Discordian, Author, Engineer, me..
"A little nonsense now and then, is relished by the wisest men" 508-755-4098
<URL:http://www.megazone.org/>  <URL:http://www.eyrie-productions.com/> Eris


------------------------------

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5273
***************************************


home help back first fref pref prev next nref lref last post