Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer


by Adam (Vicar)
on Sep 09, 2000 at 01:51 UTC ( [id://31691] : modulereview . print w/replies, xml ) Need Help??

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

Review Synopsis:


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.