Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Re: Re: capturing STDERR within a script

by leriksen (Curate)
on Mar 27, 2003 at 03: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 avoiding work at the Monastery: (7)
As of 2020-10-01 19:13 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (18 votes). Check out past polls.