Reputation: 11320
I have a perl subroutine called foo
that is in file C.pm
. C.pm
is in directory B
and that is in directory A
as follows: A > B > C.pm > foo
I'm trying to call the foo subroutine from another file. If I do the following it works:
use A::B::C qw(foo);
//Code here
foo($temp)
However, the following doesn't work
//Code here
A::B::C::foo($temp)
Why not? I thought I didn't need to include the use
statement if I explicitly wrote out the path when calling that subroutine.
Upvotes: 1
Views: 132
Reputation: 57590
The use
does two things:
require
s a file, which parses, compiles and executes itimport
method on the new module, which can install subroutines in your current namespace.You have to somehow execute a module before using subs defined in it.
If you don't want to import any subroutines or other symbols, you can give use
the empty list:
use A::B::C ();
Upvotes: 9