my $tac_pid = open my $fh, "tac $logfile |"; while (<$fh>) { last if /$match/; } kill 13, $tac_pid; # SIGPIPE close $fh;