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.
In reply to Localized STDIO and system() by mill1359
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |