Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Re: Re: capturing STDERR within a script

by leriksen (Curate)
on Mar 26, 2003 at 22:52 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2019-12-06 20:37 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (159 votes). Check out past polls.