in reply to Use, Exporter, I'm Dizzy.

Does any of the directories in your @INC contain a file test.pm?

Try putting this in your script:

END { print $INC{"test.pm"} }

and commenting out the line that triggers the error. This will tell you which test.pm was loaded. (Note that Test.pm is a standard module! If you are on Windows, maybe that's being picked up. Its filesystem is incasitive.)

Replies are listed 'Best First'.
Re^2: Use, Exporter, I'm Dizzy.
by logie17 (Friar) on Feb 07, 2007 at 17:23 UTC
    Thank you for your response, that answers one of my questions. I renamed test.pm to test2.pm and my code now looks like this:
    #! /usr/bin/perl use warnings; use strict; use test2(); my $output = testroutine(); print $output, "\n";
    Outputs...
    $ ./test.pl This is a test
    However, how come I'm even able to call testroutine? I didn't think that use would populate my name space? Is it because I don't have package defined at the top of the module? Therefore it's assuming the subroutine is part of Main? Hope that makes sense.
    Thanks again,
    s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;
      Is it because I don't have package defined at the top of the module? Therefore it's assuming the subroutine is part of Main?
      Yes. All the () on use Foo () does is suppress calling Foo->import - when the module directly defines things in the main package, or exports things in its toplevel code, that's not affected.

      I didn't think that use would populate my name space?

      Your module didn't tell perl which namespace to use, so perl placed your symbols in the currently active namespace (main). The fix is to specify a package in your module. See my post for details.

      Now that depends on the code in "test2.pm" which you have not shown up. If you're using Exporter, conventionally a statement such as

      use test2 ();

      does not export anything into the callee's namespace. You should be doing something weird and then getting weird behavior back. Take a look at the code written by ikegami at Re: Use, Exporter, I'm Dizzy. to see how the exporting code of your module should look like.