Ok,
I think I've decided to go with 'assign'
1) Because the benchmark difference isn't much:
splice 2008032/s ---3%
assign 2074689/s 3% --
2) And duplicate keys become the value of the newest hash on both ways:
use Data::Dumper;
my %w = (1=>2,3=>4);
my %q = (3=>6,7=>8);
@q{key
Thanks for the input! Bit of a brain freeze there ;p
All 3 methods have the desired effect.
Here is the benchmark info for thsoe playing along:
Benchmark: timing 100 iterations of %q = (%q, %w); , @q{keys %w} =
values %w;, my(%c)=huh(%a,%b);...
%q = (%q, %w); : 0.459673 wallclock secs ( 0.46
Jeff 'japhy' Pinyan wrote:
Gunnar Hjalmarsson said:
Jeff 'japhy' Pinyan wrote:
The general way is:
# to add %w to %q
@q{keys %w} = values %w;
If there are overlapping keys, %w's values will be used.
Why not just
%q = (%q, %w);
Benchmark it to see which is better.
The slice method seems to b
On Sep 20, Gunnar Hjalmarsson said:
>Jeff 'japhy' Pinyan wrote:
>> On Sep 19, JupiterHost.Net said:
>>>
>>>I want to add a hash to a hash,
>>>
>>>So how can I add %w to %q in that example?
>>
>> The general way is:
>>
>> # to add %w to %q
>> @q{keys %w} = values %w;
>>
>> If there are overlapp
Jeff 'japhy' Pinyan wrote:
On Sep 19, JupiterHost.Net said:
I want to add a hash to a hash,
So how can I add %w to %q in that example?
The general way is:
# to add %w to %q
@q{keys %w} = values %w;
If there are overlapping keys, %w's values will be used.
Why not just
%q = (%q, %w);
--
Gunna
On Sep 19, JupiterHost.Net said:
>I want to add a hash to a hash,
>
>So how can I add %w to %q in that example?
The general way is:
# to add %w to %q
@q{keys %w} = values %w;
If there are overlapping keys, %w's values will be used.
--
Jeff "japhy" Pinyan % How can we ever be the
- Original Message -
From: "JupiterHost.Net" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, September 19, 2004 6:56 PM
Subject: adding hash to a hash
> Howdy group,
>
> This seems like it should be simple, but I'm a bit stumped on the best
> way to do this:
>
> I want to a