# open a pipeline in which a perl one-liner feeds # word-tokenized data from $file to "word_filter"; # the FILT file handle is then used to read the output # of word_filter (one line per word): open( FILT, "perl -pe 's/^\\s*//; s/\\s+/\\n/g' $file | word_filter |" ) or die "subshell: $!"; ## note the "\\" in the one-liner while () { # $_ holds one line of output from "word_filter" # so do something with that... }