http://www.perlmonks.org?node_id=194001


in reply to [untitled node, ID 193991]

my suggestion would be to pass a reference to a hash to the subroutine; using this approach, u could pass any number of variables by just assigning a key => value to the hash, and since you're passing the hash by reference to the subroutine, you'll be able to access all the hash data inside the subroutine by simply dereferencing the hash. for example,
my %myhash = (); $myhash{'key1'} = val1; $myhash{'key2'} = val2; testsub(\%myhash); sub testsub { my $reftohash = shift; print $reftohash->{'key1'}; print $reftohash->{'key2'}; }