Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Re: capturing STDERR within a script

by leriksen (Curate)
on Mar 27, 2003 at 03:52 UTC ( [id://246161]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: capturing STDERR within a script
in thread capturing STDERR within a script

Instead of

$_;

as the last line of the sub, try

()

It has to do with the return value of the sub, which is $_ in this case, and need to be an empty list if you want no output. The return value of the sub needs to be a list suitable for processing by the original file handle. In this case silence is an empty list.

If all you want to do is capture the output, not process it, use the code from the Filter::Handle module

Filter \*STDERR, sub {push @DATA, "@_"; ()};

noisy stuff occurs...

UnFilter \*STDERR;

@DATA now holds all the noise emitted on STDERR.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found