in reply to How to process named parameters that have the same key name?

It seems to me that in order to preserve the unique values of the duplicate keys, storing an array of such values inside the hash against its key should be a candidate solution:
#!/usr/bin/perl use Data::Dumper; simple_call( uniq1 => 1, uniq2 => 2, dup1 => 3, dup1 => 4 ); sub simple_call { my %hash = (); for ( my ($key, $value); $key = shift; ) { $value = shift; if ( dupAllow( $key ) ) { unless ( $hash{ $key } ) { my @tmp = (); $hash{ $key } = \@tmp; } my $aref = $hash{ $key }; push @$aref, $value; } else { $hash{ $key } = $value; } } print Dumper( \%hash ); # continue subroutine processing } sub dupAllow { my $key = shift; ( $key eq 'dup1' ) and return 1; ( $key eq 'dup2' ) and return 1; return 0; }
Output:
$VAR1 = { 'dup1' => [ 3, 4 ], 'uniq1' => 1, 'uniq2' => 2 };

-M

Free your mind