in reply to Perl Variables

That's probably not a good idea. That said, eval might be the answer.

sub xyz { my ($tgs) = @_; return eval <<"END_OF_SUB_XYZ"; my %Test_hash_$tgs; my \$other = "Why did I do this?"; print "\$other Now I have to escape so many things.\n"; END_OF_SUB_XYZ ; }

But again, let me emphasize, I do not recommend that.

Then again, maybe a symbolic reference would work, but that's disallowed by use strict.

sub xyz { my ($tgs) = @_; my $hash_name = "Test_Hash_$tgs"; my %{$hash_name}; }

My guess is that it would be best to have a hash of hashes.

sub xyz { my ($tgs) = @_; my %Test_hash{$tgs} = {}; # use $Test_hash{$tgs}{foo}, etc. }

It might help to have a look at perlref.