http://www.perlmonks.org?node_id=1217298

TonyNY has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

How can I read the contents of a text file and print each line one by one?

I've tried the following but it only prints "something here" a whole bunch of times.

$filename='result.txt'; open( my $fh, '<', $filename ) or die "Can't open $filename: $!"; while ( my $line = <$fh> ) { print "something here $line[0]"; print "something here $line[1]"; print "something here $line[2]"; } close $fh;

Thanks