Re: How to local-ly close a handle?
- From: Ben Morrow <benmorrow@xxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 00:55:49 +0100
Quoth "Ferry Bolhar" <bol@xxxxxxxxxxxxxxxxx>:
kj:
I know of ways to temporarily silence STDERR that actually work,
but none of them begins to approach the simplicity of any of the
examples above. Any suggestions?
Yes. How about:
system 'crazystuff 2>/dev/null';
Localizing STDERR with whatever has no impact on child processes,
because the parent process' STDERR (which the child inherits) still
remains open.
This is mostly just being picky :), but that would be better as
Localizing STDERR has no impact on child processes, because the parent
process' file-descriptor 2 (which the child inherits) remains open.
The point being that the confusion here is between Perl's STDERR and
perl's fd #2.
It will have an impact when you do a "print STDERR"
or somewhat similar, but it's meaningful with Perl commands only.
And although you can localize a typeglob (and its associated IO handle),
you can't localize a close! So if you close a file (as you did with "close
STDERR"), the file will remain closed, even when leaving the block!
The fd you closed will remain closed, but the Perl filehandle will
revert to pointing to its old fd, and thus will be open again. :)
Ben
--
The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching.
Assyrian stone tablet, c.2800 BC benmorrow@xxxxxxxxxxxxx
.
- Follow-Ups:
- Re: How to local-ly close a handle?
- From: Ferry Bolhar
- Re: How to local-ly close a handle?
- References:
- How to local-ly close a handle?
- From: kj
- Re: How to local-ly close a handle?
- From: Ferry Bolhar
- How to local-ly close a handle?
- Prev by Date: Re: Parse data structure
- Next by Date: Re: A simply regex question
- Previous by thread: Re: How to local-ly close a handle?
- Next by thread: Re: How to local-ly close a handle?
- Index(es):
Relevant Pages
|
|