This question arose from a previous one related to filtering the output of Parse::RecDescent:
http://www.perlmonks.com/index.pl?node_id=209943I thought I would reproduce it in a new thread, as the old one is now rather buried in the chain.
In the example code below, the prints come through fine but the writes do not. It seems as though writes to a format cannot be tied:
use strict; use warnings; package Log::OPG::Info; use Tie::Handle; use base qw(Tie::StdHandle); sub WRITE { print "Good\n"; } package main; format STDERR = Bad . tie *STDERR, 'Log::OPG::Info'; print STDERR ''; write STDERR;
Whereas I hope for the output:
Good Good
I actually get:
Good Bad
So, either I am missing something obvious, or the question is:
"How does one tie writes to a format?"
Cheers Kevin
P.S. I faintly remember that it is possible to name individual slots in hash table entries, along the lines of $::slot{SCALAR} and $::slot{FORMAT}. Perhaps that might form the basis for a solution, but the details escape me.
In reply to Tie'ing writes to formats by ruscoekm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |