http://www.perlmonks.org?node_id=659898


in reply to Open a file on a specific file descriptor?

I don't understand if you're trying to use those programs or to recreate similar ones.

In the former case, your Perl program already has the child, so file descriptors 6 and 7 will be open when your program is started, and the two opens in your example should more or less work. In this case, you can also take a look at IO::Handle to get handles for file descriptors you already have.

OTOH, if you want to recreate the same "effect", you should probably first ask yourself if it really makes sense (e.g. maybe redirecting child's STDIN and STDOUT just before calling exec can be acceptable), then use dave_the_m's suggestion.

Update: added stuff about IO::Handle

Hey! Up to Dec 16, 2007 I was named frodo72, take note of the change! Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Io ho capito... ma tu che hai detto?