mill1359 has asked for the wisdom of the Perl Monks concerning the following question:
For some reason I can't quite figure, the localizing of the STDIO handles is not being respected by calls to system(). It really seems like this should work.
With only before and after going to the screen and the output of 'ls' going to the file, but it all goes to the screen.my $file = "file.txt"; print "before\n"; { local *STDOUT; open (STDOUT, ">$file") or die; system("ls"); } print "after\n";
Any thoughts?
P.S. I want to avoid getting the shell involved in my system call, so I don't want to use shell redirection.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Localized STDIO and system()
by ikegami (Patriarch) on Jan 30, 2009 at 19:52 UTC | |
|
Re: Localized STDIO and system()
by shmem (Chancellor) on Jan 30, 2009 at 19:49 UTC | |
|
Re: Localized STDIO and system()
by hbm (Hermit) on Jan 30, 2009 at 19:47 UTC | |
by shmem (Chancellor) on Jan 30, 2009 at 19:51 UTC | |
by ikegami (Patriarch) on Jan 30, 2009 at 20:05 UTC |