in reply to Functions that know which package they've been exported to.
That seems like an obscure and complicated way of achieving something simple:
MyLogger.pm:
package MyLogger; require Exporter; our @ISA = qw[ Exporter ]; our @EXPORT = qw[ logMessage ]; sub logMessage { print STDERR caller() . '::' . shift(); }
MyScript.pl
#! perl -slw use strict; package MyScript; use MyLogger; logMessage( 'hello' ); package main; use MyLogger; logMessage( 'hello' );
Outputs:
c:\test>MyScript.pl MyScript::hello main::hello
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Functions that know which package they've been exported to.
by tobyink (Canon) on Jan 24, 2012 at 09:42 UTC | |
by BrowserUk (Patriarch) on Jan 24, 2012 at 09:48 UTC |