Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Combining arrays of hashes

by broquaint (Abbot)
on Jul 09, 2003 at 10:39 UTC ( [id://272645]=note: print w/replies, xml ) Need Help??


in reply to Combining arrays of hashes

If I understand your question correctly this should do it
## untested code follows ... my($max,$min) = @array1 > @array2 ? (\@array1, \@array2) : (\@array2, \@array1); my @keys = qw/ year month day hhmm /; my @newarray; for my $i (0 .. @$max) { last if $i >= @$min; if(@keys == grep { $array1[$i]->{$_} eq $array2[$i]->{$_} } @keys) { push @newarray => { %{ $array1[$i] }, data2 => $array2[$i]->{data2} }; } else { push @newarray => $array1[$i], $array2[$i]; } }

HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://272645]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-29 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found