I'd like to read several consective lines from a file. Could someone show me how to do it. I know i can put several foreach loops, but it is very clumsy. Thanks.
Here what i did:
open (FILE, "t") || die "can't open t.num: $!";
# create an array of the the file content
@input = <FILE>;
# close the file to save memory
close (FILE) || die "can't open t.hex: $!";
# set your stop line
$stop1 = ":10070000";
# loop throgh each line of the array &
foreach $line(@input)
{
# if the line contains your stop parameter get out
if ($line =~ /$stop1/i){
$tmp1=$line; # read one line
#read next line : How to do this?????
$tmp2=next line;
$tmp3=next line;
last;
}
}
Here what i did:
open (FILE, "t") || die "can't open t.num: $!";
# create an array of the the file content
@input = <FILE>;
# close the file to save memory
close (FILE) || die "can't open t.hex: $!";
# set your stop line
$stop1 = ":10070000";
# loop throgh each line of the array &
foreach $line(@input)
{
# if the line contains your stop parameter get out
if ($line =~ /$stop1/i){
$tmp1=$line; # read one line
#read next line : How to do this?????
$tmp2=next line;
$tmp3=next line;
last;
}
}