lanx@lanx-1005HA:/tmp$ cat Weird.pm
package Weird;
use Carp qw/cluck/;
sub tst {
cluck "cluck tst entered";
print "\nnormal output in tst()...\n";
# ...
}
sub tst2 {
tst();
}
warn "\n--- using Weird.pm\n";
tst2(); # line 17 - executed at "use Weird" time
sub import {
warn "\n--- importing from Weird.pm\n";
tst2(); # line 22 - executed at Weird::import() time
}
1;
using Weird.pm
lanx@lanx-1005HA:/tmp$ cat t_carp.pl
warn "pre use\n";
use Weird; # ab'use
warn "post use\n";
Output with stacktrace showing all modules/lines leading to problem
lanx@lanx-1005HA:/tmp$ perl -I. t_carp.pl
--- using Weird.pm
cluck tst entered at Weird.pm line 6
Weird::tst() called at Weird.pm line 13
Weird::tst2() called at Weird.pm line 17 <--- AHA !!!
require Weird.pm called at t_carp.pl line 4
main::BEGIN() called at Weird.pm line 0
eval {...} called at Weird.pm line 0
normal output in tst()...
--- importing from Weird.pm
cluck tst entered at Weird.pm line 6
Weird::tst() called at Weird.pm line 13
Weird::tst2() called at Weird.pm line 22 <--- AHA !!!
Weird::import('Weird') called at t_carp.pl line 4
main::BEGIN() called at t_carp.pl line 4
eval {...} called at t_carp.pl line 4
normal output in tst()...
pre use
post use
HTH!
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
|