in reply to redefining CORE:: names
Not sure if I'm understanding correctly what you're intending to do, but if the idea is to force the argument to write (i.e. { 42 }) to be handled as a coderef (without having to say sub {...}), using Exporter works for me:
( A.pm )
package A; use subs qw(write); # only needed if you want to call write {...} wit +hin package A itself use Exporter 'import'; @EXPORT_OK = qw(write); sub write (&) { printf "write(): $_[0] -> %s\n", $_[0]->() }
used as
package B; use A 'write'; write { 42 };
would treat { 42 } as a sub, and print out
write(): CODE(0x65eb80) -> 42
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: redefining CORE:: names
by dk (Chaplain) on Dec 10, 2007 at 14:55 UTC |