Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Challenge: Capturing stdout from a function call.

by eclark (Scribe)
on Oct 22, 2004 at 18:17 UTC ( [id://401618]=note: print w/replies, xml ) Need Help??


in reply to Challenge: Capturing stdout from a function call.

use strict; use warnings; use Perl; my $p = Perl->new; my $data = $p->eval(q{ do{ use IO::Scalar; my $result; tie *STDOUT, 'IO::Scalar', \$result; print 'some stuff'; $result; } }); print "|||$data|||\n";

If you want to run a perl script change the print line to do 'somefile.pl';

Replies are listed 'Best First'.
Re^2: Challenge: Capturing stdout from a function call.
by BUU (Prior) on Oct 22, 2004 at 20:51 UTC
    Thats an interesting idea, my only problem is that the entire script has to be recompiled and reexecuted every time I try to run it. The main reason I'm playing with Perl.pm is to be able to "cache" the compilation of perl scripts, for speed purposes. Theoretically, with the Perl->new() method, it will load and compile the script, then I can run it multiple times with the ->run method. Maybe. In your method it would have to get reloaded every time, I think.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found