in reply to Print contents of text file line by line
if you use this syntax:
what you get each time through the loop is one single line (a scalar variable, not an array).open( my $fh, '<', $filename ) or die "Can't open $filename: $!"; while ( my $line = <$fh> ) { # ... }
So you probably want to have something like this:
Update: removed an extra closing curly bracket that I had left inadvertently at the end.open( my $fh, '<', $filename ) or die "Can't open $filename: $!"; while ( my $line = <$fh> ) { print "something here $line"; }
|
|---|