William Black wrote:
Hello,
I'm trying to figure out how to read multiple lines from a file at once for
parsing. For example,, If the file contained the following:
input file
------------
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
I want to read in lines 1-4 for processing then during the next iteration
read lines 5-8. Could someone give me a could starting place?
I know of no other way than the hard way.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
while( ! eof DATA ){
my @lines = ();
for my $i ( 1 .. 4 ){
my $line = <DATA>;
push @lines, $line;
}
# process @lines
print Dumper [EMAIL PROTECTED];
}
__END__
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
--
Just my 0.00000002 million dollars worth,
--- Shawn
"Probability is now one. Any problems that are left are your own."
SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_
* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>