Chas Owens wrote:
On 7/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
On Jul 18, 6:16 am, [EMAIL PROTECTED] (Ayesha) wrote:
>
> when I use  while($line1 = <MYFILE>){
>                            $line = <MYFILE>;
>                  }

while ($line=<FH>)
      {
       print"$line";

      }

2. while ($line = <FH>) is not safe; use while (defined (my $line =
<FH>)) instead

While the explicit use of defined may have been required in pre-Perl5 versions that is not the case in current versions where defined is implied in certain circumstances.

$ perl -MO=Deparse -e'while ( $line = <> ) { }'
while (defined($line = <ARGV>)) {
    ();
}
-e syntax OK
$ perl -MO=Deparse -e'while ( $line = readdir DH ) { }'
while (defined($line = readdir DH)) {
    ();
}
-e syntax OK




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to