in reply to how to read multiple line from a file
One approach is to use the core module Tie::File. For example, if you have an input file “data.txt” containing:
the quick brown fox jumped over the unfortunate dog
Then this script:
#! perl use strict; use warnings; use Tie::File; my $filename = 'data.txt'; tie my @lines, 'Tie::File', $filename or die "Cannot tie file '$filena +me': $!"; chomp(my @text = @lines[3 .. 5]); print "\n", join(' ', @text), "\n"; untie @lines;
will produce this output:
13:01 >perl 605_SoPW.pl fox jumped over 13:06 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to read multiple lines from a file
by skyworld_chen (Acolyte) on Apr 13, 2013 at 05:05 UTC | |
by Athanasius (Archbishop) on Apr 13, 2013 at 06:08 UTC |