> -----Original Message----- > From: Kipp, James [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 18, 2002 10:32 AM > To: [EMAIL PROTECTED] > Subject: combining data structures into one array > > > I have a subroutine that returns 3 array refs. so i have: > my ($stats, $totals, $loads) = gets_stats(); > $stats and $totals are reference to arrays of arrays. $loads > is just a ref > to an array. what i want to do is is combine each "record" of > each array > into one. here is how the structures look: > $stats -> @array -> [user, cpu, mem] > $totals -> @array -> [tot_cpu, tot_mem] > $loads -> [load1, load2] > > so i would like to itereate through the records of each of > these arrays and > end up with > @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] > [ ..another record...] > [ ..another record...] ...etc.... > > I have tried a few things, but no luck
Is there a correspondence between stats and totals, such that the "nth" entry in stats matches the "nth" entry in totals? If so, you would want to say something like: push @{$stats->[$_]}, @{$totals->[$_]}, @$loads for 0 .. $#$stats; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]