BEGIN { pipe local (*IN, *OUT); while () { print OUT; # do what you need to with $_ } close OUT; open STDIN, "<&IN"; } use CGI;