develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl #113982] Reopening filehandles can clobber PerlIO layers

Thread Next
Darin McBride
July 4, 2012 13:31
Re: [perl #113982] Reopening filehandles can clobber PerlIO layers
Message ID:
On Wednesday July 4 2012 12:28:41 PM you wrote:
> If you wanted two handles that share their internal state, you
> wouldn't dup, you'd just copy a reference.  Eg.

Here's the crux of the problem - there are many times where you can't simply 
copy a reference.  STD* are probably the primary cases of this: if you need to 
redirect them, you will (eventually) need to redirect them back.  This is so 
the filehandles stay opened to the correct terminal when you're done.

Some modules do this somewhat hidden, others do it right (i.e., fork first - 
redirecting back then becomes implicit by the OS when you exit).

But I do think this is surprising.  Especially since this is the example in 
perlfunc under "open" :-/
Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About