in reply to help with Tie::Handle
I'm not sure what that code is trying to do ... Tie::Handle is typically used as a base class, in which case your BLAH package should have this line after the use Tie::Handle; line:
But even with that it looks like you're trying to have BLAH save to a scalar maybe? You pass in $output but never save it anywhere in the BLAH object you create. You then save the print data to a lexical scalar named $data that only the BLAH package can see. Maybe you mean something more like this (not tested)?our @ISA = qw(Tie::Handle);
In other words, give the tie a reference to the scalar you want it to write to.my $output = ''; # to store the output. open SECOUT, ">&STDOUT"; tie *STDOUT, 'BLAH', \$output; package BLAH; use Tie::Handle; our @ISA = qw(Tie::Handle); sub TIEHANDLE { my $class = shift; my $save_to = shift; return bless({SAVE_TO => $save_to}, class); } sub PRINT { my $self = shift; ${$self->{SAVE_TO}} .= join '', @_; }
|
|---|