RE: combining data structures into one array

2002-06-18 Thread Shishir K. Singh

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]




RE: combining data structures into one array

2002-06-18 Thread Shishir K. Singh

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]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

this won't work, will just push one array onto another. 
thanks

 -Original Message-
 From: Shishir K. Singh [mailto:[EMAIL PROTECTED]]
 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; 
 
 
 
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Bob Showalter

 -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]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

 I am assuming User, cpu, mem, tot_cpu, tot_mem are again 
 reference to an array


woops let me clarify. $stats is a ref to an array of anon arrays.
so '$stats-[0]' contains a record lie [someuser, 5.5, 10.2]
same goes for $totals
$loads just refs a single anon array: $loads = [load1, load2]

thanks


 
 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]




RE: combining data structures into one array

2002-06-18 Thread Shishir K. Singh

Do you mean to say 

push (@$stats, @$totals, $loads);

didn't work ??

-Original Message-
From: Kipp, James [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 11:23 AM
To: Shishir K. Singh; Kipp, James; [EMAIL PROTECTED]
Subject: RE: combining data structures into one array


 I am assuming User, cpu, mem, tot_cpu, tot_mem are again 
 reference to an array


woops let me clarify. $stats is a ref to an array of anon arrays.
so '$stats-[0]' contains a record lie [someuser, 5.5, 10.2]
same goes for $totals
$loads just refs a single anon array: $loads = [load1, load2]

thanks


 
 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]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James


 
 push (@$stats, @$totals, $loads);
 
 didn't work ??

haven't tried yet. get back to you in a bit
thanks again

 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James


 
 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;
 
 

no, there is not. i just want to combine the records pointed to by each
array into one record (in a new array of records). going to try Shihir's
suggestion in a few minutes.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Bob Showalter

 -Original Message-
 From: Kipp, James [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 18, 2002 11:46 AM
 To: [EMAIL PROTECTED]
 Subject: RE: combining data structures into one array
 
 
 
  
  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;
  
  
 
 no, there is not. i just want to combine the records pointed 
 to by each
 array into one record (in a new array of records). 

Well then, I can't figure out how you plan to combine the data.

How about an example with some real data?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

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]




Re: combining data structures into one array

2002-06-18 Thread Shawn

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]




Re: combining data structures into one array

2002-06-18 Thread drieux


On Tuesday, June 18, 2002, at 07:32 , Kipp, James wrote:

 I have a subroutine that returns 3 array refs. so i have:
 my ($stats, $totals, $loads) = gets_stats();

would it be possible to expose this gets_stats()
function - and/or re-think how it deals with
generating data...




ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Shishir K. Singh

Oh Simple...What threw me off is that I though you wanted to use the rest of the 
arrays in the same format as $stats which is a reference to an anonymous array of 
anonymous arrays. 

$stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2];

Now I see that you want something like this 

@stats = (user, cpu, mem, tot_cpu, tot_mem, load1, load2);


You can do this  

#
my @myVars = ();
push (@myVars, @$stats, @$totals, $loads);
##


-Original Message-
From: Kipp, James [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 12:40 PM
To: [EMAIL PROTECTED]
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]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

 
  I have a subroutine that returns 3 array refs. so i have:
  my ($stats, $totals, $loads) = gets_stats();
 
 would it be possible to expose this gets_stats()
 function - and/or re-think how it deals with
 generating data...

of course, that is what i am doing now :-). 

 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

 
 @stats = (user, cpu, mem, tot_cpu, tot_mem, load1, load2);
 
 
 You can do this  
 
 #
 my @myVars = ();
 push (@myVars, @$stats, @$totals, $loads);
 ##

tried that, it does not work. I think i have found a way though. back in a
minute.
but as drieux mentioned i think I am going to rethink how get_stats
retrieves and returns the data. 


 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: combining data structures into one array

2002-06-18 Thread Shawn

Errr,
  Well, after reading further back, I see this has already been suggested by Bob...  
According to your data, this should work fine for you...  Do you actually end up with 
$stats on some and not on others (or $totals on one and not on others) so that this 
snippet wouldn't work?

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]




RE: combining data structures into one array

2002-06-18 Thread Timothy Johnson


I think what you might want to try is this:

  push @myVars,(@$stats,@$totals,$loads);

if what you are trying to do is just add the contents of the last three
arrays to the @myVars array...

-Original Message-
From: Kipp, James [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 9:56 AM
To: 'Shishir K. Singh'; Kipp, James; [EMAIL PROTECTED]
Subject: RE: combining data structures into one array


 
 @stats = (user, cpu, mem, tot_cpu, tot_mem, load1, load2);
 
 
 You can do this  
 
 #
 my @myVars = ();
 push (@myVars, @$stats, @$totals, $loads);
 ##

tried that, it does not work. I think i have found a way though. back in a
minute.
but as drieux mentioned i think I am going to rethink how get_stats
retrieves and returns the data. 


 


-- 
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]




Re: combining data structures into one array

2002-06-18 Thread drieux


On Tuesday, June 18, 2002, at 09:40 , Kipp, James wrote:

 $totals = [
   [ 15.8, 17.2 ],
   [ 3.7, 3.9 ],
   etc
 ];


could it be that this form is like way Ugly?

note that assume a function of form:

# let us Dummy up some data
sub gets_Stats {

my @load = qw/0.1 0.2/;

my $stat = [
[ oracle, 6.8, 11.2 ],
[ ksh, 1.8, 1.2 ],
[ JoeBob, 3.3, 4.4],
];

my $total = [
[ 15.8, 17.2 ],
[ 3.7, 3.9 ],
[ 12.2, 6.66],
];

return($stat, $total, \@load);
} # end of gets_Stats

then you can unwarp it with say:

http://www.wetware.com/drieux/pbl/Auslanders/gets_stats.txt

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

Thanks everyone for your help. I am going to redo the get_stats() function
to be 'smarter', the way it is now is much to messy.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

well done. but as you said the form is way ugly. I have adjusted the sub
to return array refs that i can easily deal with.


 -Original Message-
 From: drieux [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 18, 2002 1:35 PM
 To: begin begin
 Subject: Re: combining data structures into one array
 
 
 
 On Tuesday, June 18, 2002, at 09:40 , Kipp, James wrote:
 
  $totals = [
  [ 15.8, 17.2 ],
  [ 3.7, 3.9 ],
  etc
  ];
 
 
 could it be that this form is like way Ugly?
 
 note that assume a function of form:
 
 # let us Dummy up some data
 sub gets_Stats {
 
   my @load = qw/0.1 0.2/;
   
   my $stat = [
   [ oracle, 6.8, 11.2 ],
   [ ksh, 1.8, 1.2 ],
   [ JoeBob, 3.3, 4.4],
   ];
 
   my $total = [
   [ 15.8, 17.2 ],
   [ 3.7, 3.9 ],
   [ 12.2, 6.66],
   ];
 
   return($stat, $total, \@load);
 } # end of gets_Stats
 
 then you can unwarp it with say:
 
 http://www.wetware.com/drieux/pbl/Auslanders/gets_stats.txt
 
 ciao
 drieux
 
 ---
 
 
 -- 
 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]




RE: combining data structures into one array

2002-06-18 Thread Kipp, James

cool. the 'getRemLoad' sub is going to come in handy during this project
thanks.


 
 then you can unwarp it with say:
 
 http://www.wetware.com/drieux/pbl/Auslanders/gets_stats.txt
 
 ciao
 drieux
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: combining data structures into one array

2002-06-18 Thread Felix Geerinckx

on Tue, 18 Jun 2002 17:43:24 GMT, James Kipp wrote:

 Thanks everyone for your help. I am going to redo the get_stats()
 function to be 'smarter', the way it is now is much to messy.

No wonder you come to that conclusion after the odd 20, dare I say,
messy answers in this thread. 

Let's go back to one of your clarifications:

 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...
);

could this line possibly do what you want:

   push @stats, [@{$stats-[$_]}, @{$totals-[$_]}] 
for (0..$#$stats);

under the assumption that $stats and $totals are refs to parallel
arrays? 


(Note to contributors to this thread: please remember that a reply should 
*help* the OP, not confuse him/her even further ;-)

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: combining data structures into one array

2002-06-18 Thread drieux


On Tuesday, June 18, 2002, at 10:52 , Kipp, James wrote:

 well done. but as you said the form is way ugly. I have adjusted the sub
 to return array refs that i can easily deal with.

 On Tuesday, June 18, 2002, at 09:40 , Kipp, James wrote:

 $totals = [
 [ 15.8, 17.2 ],
 [ 3.7, 3.9 ],
 etc
 ];


I bumped my head into the problem because i had originally
coded up the fix in the form

my @totals = [
[ 15.8, 17.2 ],
[ 3.7, 3.9 ],
etc
];

return(..., \@totals);

and noticed that the simplest solution was if I fixed that
to be

my @totals = (
[ 15.8, 17.2 ],
[ 3.7, 3.9 ],
etc
);

return(..., \@totals);

There is also the 'issue' in this gets_stuff() function
that you seem to be on the rightish track of passing
back the reference to the array - vice the usual horror
of trying to return say

return(@list1, @list_shurgged, @lost_list_too)l


and noticing that your

my (@this, @that, @theNextThing) = get_stuff();

put it all in @this

You might want to think of a hash thing keying on User,
so that you can quickly get at the user's foo with

my $returnedStuff = get_stuff()

if ( exists $returnedStuff-{$username} ) {
# we know that we have that line of data
}else{
# whine that $username not be in our stuff
}


 then you can unwarp it with say:

 http://www.wetware.com/drieux/pbl/Auslanders/gets_stats.txt

ciao
drieux

---

Truth may not always be Beautiful,
but Ugly be a sign of a design Feature with Fangs
about to byte you where it counts
- Uncle Drieux's Kritikal Maxims for Software Design



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




getRemLoad is okIsh was Re: combining data structures into one array

2002-06-18 Thread drieux


On Tuesday, June 18, 2002, at 10:55 , Kipp, James wrote:

 cool. the 'getRemLoad' sub is going to come in handy during this project
 thanks.
[..]
 then you can unwarp it with say:

 http://www.wetware.com/drieux/pbl/Auslanders/gets_stats.txt


You might want to get in touch with

Net::Cmd

or
Net::Telnet

since there are security issues with using 'rsh' that
work OKish - but it was more a play function to screw
around with trying to generate random data


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]