From:                   "Chas. Owens" <[EMAIL PROTECTED]>
> On Tue, Feb 26, 2008 at 5:51 AM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> snip
> >  No need for source filters. All you have to do is to implement
> >  whatever special behaviour you need for a tied (magical) filehandle
> snip
> 
> That works for that file handle, but he/she is talking about replacing
> all print calls in a set of scripts with a custom version.  That means
> there might be prints to stdout, stderr, and numerous files.  He/she
> was trying to avoid editing the source for each program (of course,
> that is what a source filter does, but at least you only need to do it
> once).

The use statement can change where STDOUT and STDERR point to or 
select() whatever filehandle you like. Changing the behaviour of all 
filehandles (keep in mind that it would include sockets!) would not 
be a wise thing to do.

If he wants to make some more filehandles magical it would be as 
simple as

tie *FH, 'ThatPackageNameIForgotAlready', \*FH;

et voila ... all prints related to FH are special.

And actually this is in some sense more global and less work than 
source filters. Source filters are AFAIK lexicaly scoped so you'd 
have to add the use statement into each an every file. If on the 
other hand changing the STDOUT and STDERR is enough, one use 
statement in the main file suffices.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to