Leon wrote: > > From: "Casey West" <[EMAIL PROTECTED]> > > > > open FILE, "filename" or die $!; > > my $line = <FILE>; > > close FILE; > > > > Remember, <FILEHANDLE> is something you can iterate over. In scalar > > context it returns just one line (for all intents and purposes) at a > > time. > > Am I right to say that although $line reads the first line, the whole file > is still being read till the end of file.
No, it only reads the first line. > If I am sitting for a test, I failed because I would probably think that > $line = <FILE> would read the last line, I say so because of the following > reasons:- > > my @line =<FILEHANDLE>; reads every line into @line, therefore I see the > 'read FILEHANDLE' just like an array of lines like this :- > <FILEHANDLE> equivalent to ('line 1\n' , 'line2\n' ..... and so on.. ) and > if this is so, therefore $line should read the last line like this example > :- > > my $line = ( 'line1', 'line2' , 'line3' ); > print $line; # print line3 No, that is an example of the comma operator, see the perlop document for an explanation of the comma operator. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]