![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: stdout questionby trantor (Chaplain) |
on Nov 26, 2001 at 02:17 UTC ( #127434=note: print w/replies, xml ) | Need Help?? |
From what I understand, you want to eval a snippet of perl code in the current context (e.g. package, lexicals, etc.) and capture its STDOUT. Backticks do not allow you to do it, even though you can execute perl code in that way and capture STDOUT with no problems thanks to the backtick interpolation. If you use tie and IO::Scalar, you can actually execute a piece of perl code through eval and capture one or more of its filehandles. Basically using tie (reading perltie first) is a powerful way for achieving this and many other "fancy" results. This is an example of code:
Using Super Search, it is possible to find other useful threads like capturing STDOUT. Also note that this leads to major security issues, i.e. if your code is not carefully constructed/screened before being evalled. UPDATE: fastolfe came first using IO::Scalar but he's using select ;-) -- TMTOWTDI
In Section
Seekers of Perl Wisdom
|
|