Perl: reference to subroutine in external .pm file
Posted
by Pmarcoen
on Stack Overflow
See other posts from Stack Overflow
or by Pmarcoen
Published on 2010-04-06T13:48:52Z
Indexed on
2010/04/06
13:53 UTC
Read the original article
Hit count: 220
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
© Stack Overflow or respective owner