talexb has asked for the wisdom of the Perl Monks concerning the following question:

Update: I'm an idiot. I had a typo, as toolic has pointed out. Thanks.

I'm seeing some odd behaviour that someone will no doubt be able to explain.

If I try to use a module method without using the module first, I get a somewhere misleading error ..

[foo@bar test]$ perl -de 1 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> $time = Time::Local::timelocal(0,0,13,26,8,2009) Undefined subroutine &Time::Local::timelocal called at (eval 7)[/fooba +r/system/pkg/perl-5.8.6/lib/5.8.6/perl5db.pl:628] line 2.
Yet both of the following are fine:
[foo@bar test]$ perl -de 1 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> use Time::Local DB<2> $time = Time::Local::timelocal(0,0,13,26,8,2009) DB<3> x $time 0 1253962800
and
[foo@bar test]$ perl -de 1 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> use Time::Local DB<2> $time = timelocal(0,0,13,26,8,2009) DB<3> x $time 0 1253962800
However, declaring the module from the command line doesn't work ..
[foo@bar test]$ perl -MLocalTime -de 1 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. Can't locate LocalTime.pm in @INC (@INC contains: /foobar/system/pkg/p +erl-5.8.6/lib/5.8.6/sun4-solaris /foobar/system/pkg/perl-5.8.6/lib/5. +8.6 /foobar/system/pkg/perl-5.8.6/lib/site_perl/5.8.6/sun4-solaris /f +oobar/system/pkg/perl-5.8.6/lib/site_perl/5.8.6 /foobar/system/pkg/pe +rl-5.8.6/lib/site_perl /foobar/system/lib/site_perl .). at -e line 0 main::BEGIN() called at LocalTime.pm line 0 eval {...} called at LocalTime.pm line 0 BEGIN failed--compilation aborted. at -e line 0 Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info.
Can someone point me to what's happening here? Thanks.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re: Module hide and seek
by toolic (Bishop) on Aug 26, 2009 at 17:34 UTC
    However, declaring the module from the command line doesn't work .. [foo@bar test]$ perl -MLocalTime -de 1
    Did you intentionally switch modules for a reason, or did you really mean (which does not give me an error):
    perl -MTime::Local -de 1

    In your 1st 3 examples, you used Time::Local, but in your last example, you used LocalTime, which does not seem to exist on CPAN.

      Sigh. Quite right. Thank you. Egg is now securely plastered all over my face.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        That's an admission I can vote for. talexb++