Hello Jim, how about something along these lines: for(0..$#{$stats}) { push @stats, $stats->[$_],$totals->[$_]; }
Shawn ----- Original Message ----- From: "Kipp, James" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 18, 2002 11:40 AM Subject: RE: combining data structures into one array > Shishir and Bob, > > still can't get it to work. also decided we can leave out $loads, so > basically i want to combine $stats and $totals. as bob suggested, here is > sample data: > ($stats, $totals, $loads) = gets_stats(); > when the get_stats() func is called $stats will contain something like this: > > $stats = [ > [ "oracle", 6.8, 11.2 ], > [ "ksh", 1.8, 1.2 ], > ....etc.... > ]; > > and $totals will have something like: > > $totals = [ > [ 15.8, 17.2 ], > [ 3.7, 3.9 ], > ....etc.... > ]; > > so i want to end up with something like: > @stats = ( > ["oracle", 6.8, 11.2,15.8, 17.2 ], > ["ksh", 1.8, 1.2, 3.7, 3.9 ], > ....etc... > ); > > ---- > thanks. > > > -----Original Message----- > > From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, June 18, 2002 11:04 AM > > To: Kipp, James; [EMAIL PROTECTED] > > Subject: RE: combining data structures into one array > > > > > > Oops..your Requirements was different.. > > > > To achieve, @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] > > > > you need to do > > > > push (@$stats, @$totals, $loads); > > > > I am assuming User, cpu, mem, tot_cpu, tot_mem are again > > reference to an array > > > > > > Cheers > > Shihir > > > > > > -----Original Message----- > > From: Shishir K. Singh > > Sent: Tuesday, June 18, 2002 10:55 AM > > To: Kipp, James; [EMAIL PROTECTED] > > Subject: RE: combining data structures into one array > > > > > > push (@myVar, @$_) for @$stats; > > push (@myVar, @$_) for @$totals; > > push (@myVar, $_) for @$loads; > > > > > > > > > > -----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. > > > > Thanks > > Jim > > > > > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]