9 ms·
Perl5: my %merged = ( %first, %second, %third, extra => entries, %etc ); # or slightly more efficient, in-place update one hash with another @merged{keys
by falsedan 9y ago
Perl5:
my %merged = ( %first, %second, %third, extra => entries, %etc );
# or slightly more efficient, in-place update one hash with another
@merged{keys %other} = values %other;
Every statement in Perl5 is an expression, so they're trivial to compose.
- tyingq 9y agoI like Perl, and use it quite a bit. But the obvious drawback of that decision is that sub(%foo,%bar) passes a merged hash. You can use refs of course, but I've seen this bite beginners a lot.
- falsedan 9y agoYeah, list context is not an obvious paradigm for beginners, and hashes in list context being a list of pairs is also a surprise.