develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24204] Dupping STDERR for reading.

Thread Previous | Thread Next
Nick Ing-Simmons
October 17, 2003 07:07
Re: [perl #24204] Dupping STDERR for reading.
Message ID:
Abigail <> writes:
>What undocumented features are you talking about?
>>From 'man perlopentut':
>       Perl's "open" function was designed to mimic the way comĀ­
>       mand-line redirection in the shell works.
>In the shell, dupping stderr for read works just fine.
>Furthermore, the ability to open STDERR for reading isn't a Perl specific
>side-effect; it's a UNIX thing.

It depends on the UNIX though - some of them are now getting standards
compliant fussy ...

>Finally, in Perl, including 5.8.1 and 5.9.0, dupping file-descriptor 2
>for reading works fine. This works ok:
>    open STDERRIN, "<&2" or die $!;

Which seems to make a bizare kind of sense - that is how shell does 
it after all so this makes your quote above true ;-)

>and this doesn't:
>    open STDERRIN, "<&STDERR" or die $!;

What does

     open STDERRIN, "<&=STDERR" or die $!;

do ?

Come to that does 

     open STDERRIN, "<+&STDERR" or die $!;

help ? 

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About