U
usenet
I prefer this syntax when creating and populating hashes:
my %hash = (
'foo' => 'something',
'bar' => 'else'
);
But suppose that, a little later, I want to add a few more keys/values.
If it were a scalar I could add on using ".=" or if an array I could
"push" onto it - but it seems that for a hash (if I want to keep my
syntax consistent, which I do) I am forced to do something awkward
like:
%hash = (%hash, (
'bax' => 'more',
'baz' => 'stuff'
));
It works, but... is there a more elegant way?
my %hash = (
'foo' => 'something',
'bar' => 'else'
);
But suppose that, a little later, I want to add a few more keys/values.
If it were a scalar I could add on using ".=" or if an array I could
"push" onto it - but it seems that for a hash (if I want to keep my
syntax consistent, which I do) I am forced to do something awkward
like:
%hash = (%hash, (
'bax' => 'more',
'baz' => 'stuff'
));
It works, but... is there a more elegant way?