| March 2002 | Perl Hardware Store | 12 |
More usual is to have the LOG function provided by a module
If some part of your program wants to issue log messages, it will do:
use MyLogger;
LOG("Try a bigger gun!");
Where did LOG come from?
package MyLogger;
# Always export `LOG':
sub import {
# Get name of calling package
my $caller = caller;
*{$caller . '::LOG'} = \&LOG;
}
sub LOG { ... }
use MyLogger automatically calls MyLogger::import if it exists
This is how Exporter works
| Next | ![]() |
Copyright © 2002 M-J. Dominus |