in reply to computation difficulty
Now your lines are available as $lines[0] through $lines[$#lines], i.e.:open(my $INFILE, ...) or die "unable to open file: $!\n"; chomp(my @lines = <$INFILE>); close($INFILE);
Since this looks like a homework problem, I'll leave it to you to figure the rest out.print "Number of lines read: ", 1+$#lines, "\n"; for my $i (0..$#lines) { print "line $i is: $lines[$i]\n"; }
Update: Fixed bad chomp usage.
|
|---|