#! /usr/bin/perl use warnings; use strict; use test(); my $output = testroutine(); print $output, "\n";
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;
In reply to Use, Exporter, I'm Dizzy. by logie17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |