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

Re: Perl Test - Capture print statements

by Zaxo (Archbishop)
on Jul 10, 2007 at 21:34 UTC ( #625932=note: print w/ replies, xml ) Need Help??


in reply to Perl Test - Capture print statements

You could localize STDOUT, opening it to a variable.

my $out = do { my $msg; open local( *STDOUT), '>', \$msg or die $!; mytest(); $msg };
That takes Perl 5.8+ for opening a handle to a variable.

++fenLisesi caught a thinko in text, s/STDERR/STDOUT/. Repaired.

After Compline,
Zaxo


Comment on Re: Perl Test - Capture print statements
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2015-07-08 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls