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


in reply to passing hashes and hash reference

What you want to do is pass the hash reference to your sub, which expects a reference. Try:

sub myroutine { $hash_ref = (shift); $$hash_ref{foo}='bar'; } myroutine(\%thishash);


If you wanted to make sure you were getting a hash reference inside your sub, add a line like this:
die "Not a HASH reference" unless (ref($hash_ref) eq "HASH");