perl5ever has asked for the wisdom of the Perl Monks concerning the following question:
except that select($OLDFH) will always get executed when control leaves the inner block (exception, return, etc.)open(my $fh, ...); my $OLDFH; { $OLDFH = select($fh); print ...; ... } select($OLDFH);
What's a good way to do this? eval works for catching exceptions. Is there a way to do this with local() ?
Would creating an object whose DESTROY method restores the default handle work?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can the default file handle be localized?
by ikegami (Patriarch) on Mar 12, 2009 at 21:27 UTC | |
by hbm (Hermit) on Mar 12, 2009 at 21:44 UTC | |
by ikegami (Patriarch) on Mar 12, 2009 at 21:57 UTC | |
|
Re: can the default file handle be localized?
by perl5ever (Pilgrim) on Mar 12, 2009 at 22:15 UTC |