in reply to Re^3: Syncing perltie filehandle STDOUT STDERR and system call
in thread Syncing perltie filehandle STDOUT STDERR and system call
date output doesn't get default error meta text. Also this has been mentioned in Bugs section I already have a large number of pre-written scripts and trying to capture print STDERR from them, not the system generated error signals alone. So I would like to perform similar callback function for STDERR as well. Thanksuse IO::Callback; # Here's the coderef my $code = sub { my $str = shift; print STDERR "This is really bad: $str"; }; # Turn it into a filehandle opened in write mode my $fh = IO::Callback->new('>', $code); # Select that filehandle (makes it the default for print, say, etc). select($fh); # Print something - it gets passed to the coderef! print "Hello World\n"; system("date");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Syncing perltie filehandle STDOUT STDERR and system call
by jandrew (Chaplain) on Dec 26, 2012 at 18:00 UTC |