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..$#_]); } } };
In Section
Seekers of Perl Wisdom