M
mrstevegross
I've got a few variables that I'm using to create a hash: $foo, $bar,
and $baz. The keys for those values are the same as the variable
names: 'foo', 'bar', and 'baz'. Currently, I create the hash like so:
my $hsh_ref = { 'foo' => $foo, 'bar' => $bar, 'baz' => $baz };
Given that the key names are identical to the variable names, is there
a way to create the hash so that I don't have to enter the key names
explicitly? Something like (in pseudocode):
my $hsh_ref = { use_var_names_as_keys $foo, $bar, $baz };
Any ideas?
Thanks,
--Steve
and $baz. The keys for those values are the same as the variable
names: 'foo', 'bar', and 'baz'. Currently, I create the hash like so:
my $hsh_ref = { 'foo' => $foo, 'bar' => $bar, 'baz' => $baz };
Given that the key names are identical to the variable names, is there
a way to create the hash so that I don't have to enter the key names
explicitly? Something like (in pseudocode):
my $hsh_ref = { use_var_names_as_keys $foo, $bar, $baz };
Any ideas?
Thanks,
--Steve