> -----Original Message-----
> From: Wagner Garcia Campagner [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 08, 2001 12:27 PM
> To: [EMAIL PROTECTED]
> Subject: End of File
>
>
> Hi,
>
> I don't know how to tell perl EOF, i am doing a search in a
> file like this:
>
>
> $username eq 'wagner';
> $file = 'c:\file';
>
> open(INFO, $file);
> do
> {
> $lines = <INFO>;
> chop $lines;
> }
> while ($lines !~/$username/);
> close(INFO);
>
>
> The problem is if the file doesn't have a line with the word
> "wagner" it
> become a infinte looping....
>
> The while statement should be:
>
> while (($linhas !~/$username/) || EOF);
>
> But how is the correct sintax for EOF?????
>From perlop:
In scalar context, evaluating a filehandle in angle brackets yields
the next line from that file (the newline, if any, included), or
"undef" at end-of-file or on error. When "$/" is set to "undef"
(sometimes known as file-slurp mode) and the file is empty, it returns
"''" the first time, followed by "undef" subsequently.
so something like
$lines = <INFO> or last;
should do the trick. That will stop the loop at end of file.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]