http://qs321.pair.com?node_id=31691

Item Description: Apply a filter to a filehandle! Written by our own btrott

Review Synopsis:

Filter::Handle

This module was originally written here at the Perl Monks Monastery. It provides a simple interface allowing users to tie a filter subroutine to a filehandle. There are many things you could do with this... from labeling STDERR output as STDERR output to easily puting line numbers and timestamps in a logfile.

Replies are listed 'Best First'.
RE: Filter::Handle
by mirod (Canon) on Sep 11, 2000 at 21:26 UTC

    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; } }
Re: Filter::Handle
by Aristotle (Chancellor) on May 23, 2002 at 10:01 UTC
    It would have been nice if the review actually was one.. :-/
    ____________

    Makeshifts last the longest.