ninuzzo has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to do that as explained in the perlsub manpage and this blog, but wasn't able to get the first argument to the CORE::open.
Here's my code:
When I use a lexical (open $file, ...) I get undef into $_[0]. It doesn't work with a typeglob (open FILE, ...) as well. I'm at my wits' end :(package MyOpen; require Exporter; @ISA = 'Exporter'; @EXPORT_OK = 'open'; use Carp; use Data::Dumper; sub import { my $pkg = shift; return unless @_; my $sym = shift; my $where = ($sym =~ s/^GLOBAL_// ? 'CORE::GLOBAL' : caller(0)); $pkg->export($where, $sym, @_); } sub open (*;$@) { print Dumper(\@_), "\n"; return CORE::open $_[0], $_[1], $_[2]; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Override the open builtin globally
by moritz (Cardinal) on Jun 13, 2011 at 16:29 UTC | |
|
Re: Override the open builtin globally
by ikegami (Patriarch) on Jun 13, 2011 at 16:27 UTC | |
|
Re: Override the open builtin globally
by Khen1950fx (Canon) on Jun 13, 2011 at 19:47 UTC | |
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 |