With Name::Name->subroutine() you need to capture the class name as the first argument in subroutine() method.
package Name::Name;
sub subroutine {
my $class = shift; # shifting @_
print $class, "\n";
}
package main;
use Name::Name;
Name::Name->subroutine();
# output:
# Name::Name
It's callled class method calling. With Name::Name::subroutine(), you call subroutine() with fully qualified package name without any argument.
I'm not sure what's missing, but if the subroutine in question is new() then you can't call it Name::Name::new() as it expects the class name as its first argument. Similiar way to the class method calling above is Name::Name::new('Name::Name').
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
|