----- Original Message -----
From: "Michael Fowler" <[EMAIL PROTECTED]>
To: "Matt Fuerst" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, August 31, 2001 9:22 PM
Subject: Re: real stupid matching question
> On Fri, Aug 31, 2001 at 02:21:56PM -0400, Matt Fuerst wrote:
> > I am opening a file witht he following command:
> >
> > open (LOGFILE, "100.txt");
>
> Where is your "|| die(...)"?
>
>
> > $oneline = <LOGFILE>;
> > while ( $oneline =~ /(-{3,})/ )
> > {
> > # process one line
> > $oneline = <LOGFILE>;
> > }
>
> <LOGFILE> will evaluate to undef when the end of the file is reached.
>
> The typical idiom for this is:
>
> while ($onefile = <LOGFILE>) {
> last unless $oneline =~ /(-{3,})/;
> # process $oneline
> }
>
> This will guarantee $onefile is always defined, and will appropriately
exit
> out of the loop -upon- EOF, rather than try to handle the undef and then
> exit.
>
>
> > Which is not working... I get an error of use of uninitialized value at
line
> > 28,
>
> It is working. "Use of uninitialized value" is a warning, not a fatal
> error. undef doesn't match /-{3,}/. The code is working, perl is just
> complaining because your use of undef there may be incorrect.
>
>
> Michael
> --
> Administrator www.shoebox.net
> Programmer, System Administrator www.gallanttech.com
> --
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]