Tell us what you mean by not working. Do you get a syntax or runtime error, or does it print too many lines or nothing at all?
Give us an example that's easy to test. You don't want to have to type the name of the file every time you test your script, do you? Once you know the file-prompting portion of your script works, set it aside and make a testable snippet of the record-matching and printing part of the script so you can test it repeatedly and debug it.
I see at least one problem in your script:
my $next1;#Declare variable
#Do other things
#...
#$next1 still has no value
$_ = $next1;#Wipe out the current record by assigning no value. Why?
print "$_";#Print nothing?
print "$next1.\n";#Print nothing followed by period followed by newline?
d5e5
Practically a Posting Shark
831 posts since Sep 2009
Reputation Points: 162
Solved Threads: 163
Skill Endorsements: 1
I suggest that the part of your code that loops through the lines should look more like this:
my $counter = 0; #Number of lines you want to print
while (<INPUT>){
$counter = 2 if m/FrNum: 1 /;
if ($counter > 0){
print;
$counter--;#Subtract 1 from your counter
}
}
d5e5
Practically a Posting Shark
831 posts since Sep 2009
Reputation Points: 162
Solved Threads: 163
Skill Endorsements: 1