in reply to Assigning list with duplicate keys to hash
In Perl Best Practices, TheDamian recommends using a hash for default parameters like so:
my %DEFAULTS = ( a => 1, b => 2 ); sub foo { my $arg_ref = shift; my %args = ref $arg_ref eq ref {} ? ( %DEFAULTS, %{$arg_ref} ) : %DEFAULTS; }
He clearly expects the second hash to overwrite the duplicated contents of the first, so I think it's safe to say this is defined behavior that you can rely on.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Assigning list with duplicate keys to hash
by Your Mother (Archbishop) on Apr 22, 2008 at 17:23 UTC |