in reply to Override the open builtin globally
As I understand it, to override globally, you need to use CORE::GLOBAL in a BEGIN block because it has to be done at compile time.#!/usr/bin/perl use strict; use warnings; BEGIN { *CORE::GLOBAL::open = sub (*;$@) { if(defined($_[0])) { use Symbol qw(); 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..$#_]); } } }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Override the open builtin globally
by Eliya (Vicar) on Jun 13, 2011 at 20:56 UTC | |
by Anonymous Monk on Jan 15, 2017 at 09:54 UTC | |
by choroba (Cardinal) on Jan 15, 2017 at 10:17 UTC | |
by Anonymous Monk on Jan 16, 2017 at 07:57 UTC |