# monitor.pl open(INPUT, "./script |") or die $!; while() { # same as above if(/regex/) { dosomething($_); } print; } close INPUT;