http://qs1969.pair.com?node_id=31935


in reply to Filter::Handle

I have just one question: how does this compare to using a magic open?

A magic open is a really cool Perl feature that let you... set a filter on a file! Just like this:

#!/bin/perl -w use strict; set_filter(); # sets the post-processing filter print "main processing is here\n"; print "and continues here\n"; exit; BEGIN { my $i=1; sub set_filter { return if my $pid= open( STDOUT, "|-"); # magic open die "cannot fork: $!" unless defined $pid; while( <STDIN>) { printf "line %03d: %s", $i++, $_; } exit; } }