gctaylor1 has asked for the wisdom of the Perl Monks concerning the following question:
Something like this, except it doesn't work:
$hashref->{"key1"} = "value1", {"key2"} = "value2";
This seems like it should be simple and if the answer is in perlreftut or perldsc (or anywhere else) please give me a big clue because the many attempts I've made just aren't working.
I don't really have a burning need, just trying to learn
about references and hashes.
I can only add the values one at a time, as my example below demonstrates
use strict; use warnings; my %employees= ( "key1" => undef, "key2" => undef, "key3" => undef, ); my $hashref = \%employees; $hashref->{"key1"} = "value1"; $hashref->{"key2"} = "value2"; $hashref->{"key3"} = "value3"; print %$hashref,"\n";
|
|---|