in reply to Considering hash slices, past, present and future
Now it is easy to get the syntax you want:# Takes a hash reference and a list of key/value pairs. # Assigns those keys to those values in the hash sub add_to_hash { my $h_ref = shift; while (@_) { my $key = shift; my $value = shift; $h_ref{$key} = $value; } }
add_to_hash(\%my_hash, key1 => "value1", key2 => "value2", # ... );
UPDATE
Fixed typo pointed out by grinder.
|
---|
Replies are listed 'Best First'. | |
---|---|
(bbfu) (syntax suga) Re2: (tilly) 1: Considering hash slices, past, present and future
by bbfu (Curate) on Oct 26, 2001 at 07:14 UTC |