in reply to Getting next line after matched one

As you loop through the input lines just set a flag where you need to. Then when you get to the next line do whatever you need to. You might also want a check at the end of the loop to see if your input didn't end properly.
#!/usr/bin/perl -w use strict; my $line; my $pattern = "asdf"; my $flag = 0; while($line = <>) { if($flag) { print "do something here to $line \n"; } if($line =~ m/$pattern/) { $flag = 1; } else { $flag = 0; } } if($flag) { print "Oops, we don't have a line to work on but flag was set.\n"; }