while (my $line = <$info>) { my $next_line_start = tell($info); # save start position of next line if ($line =~ /regex/) { do_something_here; } # reposition at $next_line_start seek($info,$next_line_start,0); }