N
Newsgroups
Hi,
How can I globalise a hash variable with this context/example :
test.pl contains :
#!/usr/bin/perl
use myPackage;
my %hash;
$hash{"test"} = 10;
my $p = new myPackage;
$p->otherSub();
print $hash{"test"}; # will print 10; but I would like it to print 11
and myPackage.pm contains :
#!/usr/bin/perl
package myPackage;
sub otherSub {
$hash{"test"}++; # here, my hash isn't global
}
1;
And, I doesn't want to pass my hash into to sub like this :
$hash = $p->otherSub($hash{"test"}); with a "return $hash" into
otherSub.
I've tryed to use @EXPORT= qw($hash) without success.
Thanks for your advices...
How can I globalise a hash variable with this context/example :
test.pl contains :
#!/usr/bin/perl
use myPackage;
my %hash;
$hash{"test"} = 10;
my $p = new myPackage;
$p->otherSub();
print $hash{"test"}; # will print 10; but I would like it to print 11
and myPackage.pm contains :
#!/usr/bin/perl
package myPackage;
sub otherSub {
$hash{"test"}++; # here, my hash isn't global
}
1;
And, I doesn't want to pass my hash into to sub like this :
$hash = $p->otherSub($hash{"test"}); with a "return $hash" into
otherSub.
I've tryed to use @EXPORT= qw($hash) without success.
Thanks for your advices...