Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Override the open builtin globally.. redux

by Anonymous Monk
on Feb 26, 2013 at 20:18 UTC ( #1020751=note: print w/ replies, xml ) Need Help??


in reply to Override the open builtin globally.. redux

See: http://www.perl.com/pub/2002/06/11/threads.html?page=2 (at the end) The key is the handling of the undefined case.

*CORE::GLOBAL::open = sub(*;$@) { # push @OpenCalls, [ @_[1..$#_] ]; if (defined($_[0])) { use Symbol (); my $handle = Symbol::qualify($_[0],(caller)[0]); no strict 'refs'; if(@_ == 1) { return CORE::open($handle); } elsif(@_ == 2) { return CORE::open($handle, $_[1]); } else { return CORE::open($handle, $_[1], @_[2..$#_]); } } else { if(@_ == 1) { return CORE::open($_[0]); } elsif(@_ == 2) { return CORE::open($_[0], $_[1]); } else { return CORE::open($_[0], $_[1], @_[2..$#_]); } } };


Comment on Re: Override the open builtin globally.. redux
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-28 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls