On Thursday 29 Jan 2004 2:25 pm, James Edward Gray II wrote:
> On Jan 29, 2004, at 8:07 AM, Gary Stainburn wrote:
> > Hi folks,
> >
> > I've got the following code which works, but generates the error
> > message
> > following it.  I've tried varying the code to eliminate the error but
> > I only
> > manage to get either the working code with error or non-working code
> > without
> > error.
> >
> > (Line 95 is the while line)
> >
> >       print "checking file $fname...";
> >       open DAT,"<$fname" ||die "cannot open $fname: $!\n";
> >       my $found=0;
> >       while ((my $line=<DAT>) && (! $found)) {
> >     print "line=$line" if ($DEBUG > 0);
> >         $found=1 if $line=~/$localpart:/;
> >       }
>
> How about we simplify that loop a little:
>
> while (<DAT>) {
>       print "line=$_" if $DEBUG;
>       last if /$localpart/;
> }

Hi James,

my problem was having the result in $found after the loop ended, I've amended 
your code so that I have 

if (/$localpart:/) { $found=1; last;}

Thanks for the help.

Gary

>
> That's a little easier on the eyes, I think.  It means the same and it
> will remove the error.
>
> Hope that helps.
>
> James
>
> >       close DAT;
> >
> > [EMAIL PROTECTED] input]# tidy-mailq|gvim -
> > Value of <HANDLE> construct can be "0"; test with defined() at
> > /root/bin/tidy-mailq line 95.
> > Vim: Reading from stdin...
> > [EMAIL PROTECTED] input]#
> > --
> > Gary Stainburn
> >
> > This email does not contain private or confidential material as it
> > may be snooped on by interested government parties for unknown
> > and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > <http://learn.perl.org/> <http://learn.perl.org/first-response>

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to