in reply to Getting module to call importer's function
How about:
use strict; package M; sub x { my $caller_package = shift; print "Caller: $caller_package\n"; $caller_package->_x(); } package main; sub _x { my $class = shift; print "$class _x\n"; } main->M::x();
output:
Caller: main main _x
update: added "shift" in _x - thanks ikegami.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting module to call importer's function
by ikegami (Patriarch) on Sep 22, 2004 at 21:33 UTC | |
by jredburn (Sexton) on Sep 22, 2004 at 21:44 UTC | |
by ikegami (Patriarch) on Sep 22, 2004 at 21:47 UTC | |
by fglock (Vicar) on Sep 23, 2004 at 04:36 UTC |