Quantcast
Channel: proc_open: Extending file descriptor numbers to enable "status" feedback from a Perl script - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by mob for proc_open: Extending file descriptor numbers to enable "status" feedback from a Perl script

$
0
0

You open a new filehandle and dup it to file descriptor 3:

open STD3, '>&3';
print STDERR "foo\n";
print STD3   "bar\n";

$ perl script.pl 2> file2 3> file3
$ cat file2
foo
$ cat file3
bar

Edit: per Greg Bacon's comment, open STD3, '>&=', 3 or open STD3, '>&=3' opens the file descriptor directly, like C's fdopen call, avoiding a dup call and saving you a file descriptor.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>