George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:
But what if, instead of hashes I have hash references? In my case this happens because I'm merging the output of two DBI calls, having fetched my data by doing $sth->fetchrow_hashrefs. I could just do@old{keys %new} = values %new;
and then proceed as before; but that seems like a needless proliferation of data structures. And in fact, having written this out, I realise I could also use $sth->fetchrow_array to get my data from the db, and then create a single new hash to store the elements from my two new hashes.my %old = %$old; my %new = %$new;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Slicing a hashref
by Juerd (Abbot) on Jan 19, 2002 at 19:42 UTC | |
|
Re (tilly) 1: Slicing a hashref
by tilly (Archbishop) on Jan 19, 2002 at 20:52 UTC | |
|
Re: Slicing a hashref
by broquaint (Abbot) on Jan 19, 2002 at 19:47 UTC | |
|
Re: Slicing a hashref
by trs80 (Priest) on Jan 19, 2002 at 20:27 UTC | |
by trs80 (Priest) on Jan 20, 2002 at 05:40 UTC |