Beginner wrote:
> On 16 Jun 2006 at 12:15, Paul Johnson wrote:
>
>>On Tue, Jun 13, 2006 at 12:06:02PM -0700, Lawrence Statton wrote:
>>
>>>Charles Clarkson wrote:
>>>> @{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;
>>>You can excise a little of the snyactic sugar there
>>>
>>>@$hash_ref{keys %kv_pairs} = values %kv_pairs;
>>%hash = (%hash, %kv_pairs);
>>
>>hmmm, tradeoffs ...
>
> Would anyone care to explain what any of these varations do? Are they all
> slices?
@{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;
Which should really be:
@{ $hash_ref }{ keys %kv_pairs } = values %kv_pairs;
But the '%' is allowed for backward compatibility, and:
@$hash_ref{ keys %kv_pairs } = values %kv_pairs;
Do exactly the same thing - they add the keys and values of %kv_pairs to
$hash_ref (using a hash slice.)
%hash = ( %hash, %kv_pairs );
Creates a list of all the keys and values of %hash and %kv_pairs and assigns
that list to %hash overwriting its previous contents.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>