Wiggins, I think I almost have it but maybe someone can unstrangle my hair on this Last piece.
Here is what I have now: foreach $items (sort %commands) { foreach $CMD (sort keys %{$commands{$items}}){ print "Command: $CMD \n"; $results= ($commands{$items}{$CMD})[0]; print "$results \n"; } } Below is my results: C:\Perl\Accenture>perl test2.pl Command: cpu psrinfo | awk '{print $1}' | wc -l Command: hostname uname -n Command: memory prtconf | grep Memory | awk '{print $3}' Command: os uname -s Command: osrel cat /etc/release | awk '{print $3}' Command: osver uname -r Command: srvmodel uname -i | cut -f2 -d "," Command: srvtype uname -p But what is frustrating is that it is close but still doesn't Sort the routine. If I had to compare the hash in some way maybe It could sort better that way. Any thoughts? Phillip -----Original Message----- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 12:33 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Hash Issue > > Hi, > > > > I've been playing around with the Tie::IxHash module. > > > > Here is my part of my code: > It appears to be lacking, use strict and use warnings these will help you track down on your own your errors.... > > > tie my %commands, "Tie::IxHash"; > > > > %commands = ('sol'=>{'hostname' =>'uname -n', > > 'os' =>'unamed -s', > > 'over' =>'uname -r', > > 'osrel' =>'cat /etc/release | awk > \'{print $3}\'', > > 'srvtype' =>'uname -p', > > 'srvmodel' =>'uname -i | cut -f2 -d ","', > > 'memory' =>'prtconf | grep Memory | awk > \'{print $3}\'', > > 'cpu' =>'psrinfo | awk \'{print > $1}\' | wc -l'} > > ); > > I haven't used the tied hash much, but assuming it works as a regular has as it should... > > > > foreach $OS (keys %commands){ > Right here $OS contains a hash reference to the inner hash for the particular operating system... > print "OS: $OS \n"; > > while (( $OS, $CMD ) = each %commands ) { > Right here you are eaching over %commands inside a foreach on keys which is probably not what you want, and is probably doing screwy things, like resetting the position indicator of the hash.... And you are also clobbering your preset $OS which means you can no longer access that particular hash to loop over. > print "$OS Commands are $items .\n"; ***** > Where did $items come from in the first place. > } > > } > > > > If I change the $items variable in the print statement where the asterisk is > to $CMD I get nothing but a hex value output. Has anyone have a suggestion > what I'm doing wrong. > How about: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } I was thinking that your use of the tied hash was to get the commands to run in order rather than the OS's (maybe I missed part of this discussion) if that is the case the inner hashes must be the tied variants, rather than the outer..... perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]