logie17 has asked for the wisdom of the Perl Monks concerning the following question:
Could somebody please explain why the following does this?
and this has the same result...
Thanks!
#! /usr/bin/perl use warnings; use strict; use test(); my $output = testroutine(); print $output, "\n";
and this has the same result...
the result being...#! /usr/bin/perl use warnings; use strict; use test; my $output = testroutine(); print $output, "\n";
If I run the following:Undefined subroutine &main::testroutine called at ./test.pl line 8.
Now if I alter test.pl to look like:$ perl -e 'map {print $_,"\n"} @INC' /usr/lib/perl5/5.8/cygwin /usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 .
When run, the program outputs the following:#! /usr/bin/perl use warnings; use strict; use lib '.'; #My Change use test(); my $output = testroutine(); print $output, "\n";
For information test.pm which is in the same directory as test.pm has the following code:This is a test
Now I may be very ignorant of the use. However, I would expect my first example to work if my second example works. Why would enabling use lib import the module into my namespace? When before I use use lib, '.' is in my @INC. Second, I would think that in actuality both examples should fail since I'm calling test.pm by use test(), I would think this would NOT populate anything into my namespace? I hope this long post makes sense, for I am eager to learn.sub testroutine { return "This is a test"; } 1;
Thanks!
s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Use, Exporter, I'm Dizzy.
by ikegami (Patriarch) on Feb 07, 2007 at 17:20 UTC | |
by logie17 (Friar) on Feb 07, 2007 at 17:30 UTC | |
by ikegami (Patriarch) on Feb 07, 2007 at 17:33 UTC | |
by caelifer (Scribe) on Feb 07, 2007 at 17:52 UTC | |
by ikegami (Patriarch) on Feb 07, 2007 at 17:55 UTC | |
by caelifer (Scribe) on Feb 07, 2007 at 18:25 UTC | |
Re: Use, Exporter, I'm Dizzy.
by ferreira (Chaplain) on Feb 07, 2007 at 17:16 UTC | |
Re: Use, Exporter, I'm Dizzy.
by gaal (Parson) on Feb 07, 2007 at 17:17 UTC | |
by logie17 (Friar) on Feb 07, 2007 at 17:23 UTC | |
by ysth (Canon) on Feb 07, 2007 at 17:28 UTC | |
by ikegami (Patriarch) on Feb 07, 2007 at 17:32 UTC | |
by ferreira (Chaplain) on Feb 07, 2007 at 17:36 UTC | |
Re: Use, Exporter, I'm Dizzy.
by dirving (Friar) on Feb 07, 2007 at 17:29 UTC | |
Re: Use, Exporter, I'm Dizzy.
by johngg (Canon) on Feb 07, 2007 at 19:24 UTC | |
by Anonymous Monk on Feb 07, 2007 at 19:36 UTC | |
Re: Use, Exporter, I'm Dizzy.
by Anonymous Monk on Feb 07, 2007 at 18:16 UTC |
Back to
Seekers of Perl Wisdom