[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Copying hashes



On Sun, Jan 30, 2000 at 03:05:45PM -0600, Andy Lester wrote:
> I'm using the following little snippet of code:
>     my $r = $sth->fetchrow_hashref() or return 0;
>     $self->{keys %$r} = $self->{values %$r};
> 
> I can't imagine there's a better way to plug the values from %$r into my
> hash, but I figure it's worth asking about...

People have discussed allowing

push %$self, %$r;  # keys in %$r override keys in %$self

or

unshift %$self, %$r;  # keys in %$self override keys in %$r

I like it.

Andrew

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe