Perl: reference to subroutine in external .pm file
- by Pmarcoen
I'm having some trouble figuring out how to make a reference to a subroutine in an external .pm file.
Right now, I'm doing this :
External file
package settingsGeneral;
sub printScreen {
print $_[0];
}
Main
use settingsGeneral;
my $printScreen = settingsGeneral::printScreen;
&$printScreen("test");
but this result into an error:
Can't use string ("1") as a subroutine ref while "strict refs" in use