dear all,
i'm trying to figure out how a perl module accesses a global variable.
below i show listings for the module (Hello.pm) and the program
(testmodule.pl). testmodule defines a global variable which i'd like
to know how to access from within Hello.pm.
anyone know how to do this?
thanks!
pete
Hello.pm:
package Hello;
require Exporter; # } These set up an import
@ISA = qw(Exporter); # } method, called implicitly
@EXPORT = qw( say_hello ); # } by use().
sub say_hello {
print "Hello, world!\n";
print $globalvariable . "\n";
}
return 1;
testmodule.pl:
#!/usr/bin/perl -w
use diagnostics;
use Hello;
my $globalvariable = "hello world";
print "using scope specifier:\n";
Hello::say_hello();
print "now without scope specifier:\n";
say_hello();