develooper Front page | perl.beginners | Postings from May 2007

if (<FH>) VS while (<FH>)

Thread Next
From:
jeevs
Date:
May 29, 2007 07:13
Subject:
if (<FH>) VS while (<FH>)
Message ID:
1180445395.038101.255220@o11g2000prd.googlegroups.com
If (<FH>) ::: if doesn't not fill the $_ variable with contents of
files first line automatically.
While (<FH>) ::: while do fill the $_ to content of the files first
line automatically.

i.e
open FH, "name.txt" or die "cant open";
if  (<FH>){
print "$_";
}

prints nothing
If we change if to while $_ is set to first line of the file... how
can this happen


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About