I would use oo to solve this, an object keeps all the vals for you that you need, and you can do lots more with them as you pass on.
#!/usr/bin/perl
use strict;
my $obj = blah->new();
sub A() {
print( $obj->getName . " , " . $obj->{address} . "\n" );
}
sub B() {
print( $obj->getName . " , " . $obj->{address} . "\n" );
}
A;
B;
package blah;
use strict;
sub new() {
my $classname=shift;
my $self=bless{};
$self->{name} = "Sam";
$self->{address} = "123 Main st";
return $self;
}
sub getName() {
my $self=shift;
if ($self->{name}) {
return $self->{name};
} else {
#Init name and return value...
}
}
1;
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.