open my $INPUT, "<", $ARGV[0] or die "I couldn't get at input text"; open my $SAME_INPUT, "<", $ARGV[0] or die "I couldn't get at input text"; my $offset = $ARGV[1]; my $line = <$INPUT> for (1..$offset); # discard the n first lines, can't do anything with them anyway while (<$INPUT>) { $line = <$SAME_INPUT>; print $line if /$regex/; }