At first, please take a look at the following codes:
File 'test1.pl':
File 'test2.pm':
The outputs:
My question: are there any other ways to get $str in test2.pm w/o calling test2::getStr? Maybe I should use 'import'? But I don't know how.
Thanks for your help.
File 'test1.pl':
Code:
#! /usr/bin/perl
use strict;
use test2;
my $thisStr = &getStr;
print "\$thisStr = $thisStr\n";
print "##$test2::str##\n";
File 'test2.pm':
Code:
use strict;
use vars qw(@ISA);
use vars qw(@EXPORT);
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
test
);
my $str = "Can you see this?";
sub getStr {
return $str;
}
return 1;
The outputs:
Code:
% ./test1.pl
$thisStr = Can you see this?
####
My question: are there any other ways to get $str in test2.pm w/o calling test2::getStr? Maybe I should use 'import'? But I don't know how.
Thanks for your help.