Perl: Declaring Hash Names Dynamically

For advanced Perl programmers, this may come handy anytime when you have to generate a hash with a dynamic naming convention for temporary processing purposes.

[code language=”perl”]
C:\>perl
$a = "Test";
%{"$a"} = ( ‘TestKey’ => ‘TestValue’ );
print keys %{"$a"};
^D
TestKey
C:\>
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *