in reply to Adding multiple items to a hash

sub hpush (\%@) { my ($hash, %add) = @_; $hash->{$_} = $add{$_} for keys %add; } my %config = ( home => '/home/foo', temp => '/tmp' ); hpush %config, root => '/root', sbin => '/usr/sbin';

Replies are listed 'Best First'.
Re: Re: Adding multiple items to a hash
by Stevie-O (Friar) on Mar 03, 2004 at 00:14 UTC
    Just for my $.02:
    sub hpush (\%@) { my ($hash, %add) = @_; @{$hash}{keys %add} = values %add; }
    --Stevie-O
    $"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc