in reply to Print contents of text file line by line

Hi TonyNY,

if you use this syntax:

open( my $fh, '<', $filename ) or die "Can't open $filename: $!"; while ( my $line = <$fh> ) { # ... }
what you get each time through the loop is one single line (a scalar variable, not an array).

So you probably want to have something like this:

open( my $fh, '<', $filename ) or die "Can't open $filename: $!"; while ( my $line = <$fh> ) { print "something here $line"; }
Update: removed an extra closing curly bracket that I had left inadvertently at the end.