in reply to Re^5: Reassign STDOUT/STDERR contents to a variable
in thread Reassign STDOUT/STDERR contents to a variable
Figured it out. The difference was that in the script that is to be executed via the eval, you can't rely on the special <> anymore it would seem.
Executing the following code results in printing the PerlIO man page.
my $script = 'while(<>) { print; }'; close(STDIN); open (STDIN,'<',\my $stdin); my $script_input = 'blah'; $stdin .= $script_input; eval $script;
Wheras executing this code works fine:
my $script = 'while(<STDIN>) { print; }'; close(STDIN); open (STDIN,'<',\my $stdin); my $script_input = 'blah'; $stdin .= $script_input; eval $script;
Any thoughts on how to workaround this? I like <>.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Reassign STDOUT/STDERR contents to a variable
by Anonymous Monk on Sep 27, 2009 at 02:19 UTC | |
|
Re^7: Reassign STDOUT/STDERR contents to a variable
by Anonymous Monk on Sep 27, 2009 at 02:24 UTC | |
by lothos (Novice) on Sep 28, 2009 at 06:06 UTC | |
|
Re^7: Reassign STDOUT/STDERR contents to a variable
by ikegami (Patriarch) on Sep 27, 2009 at 03:23 UTC |