Marza has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks, I am writing a script that will search our domain and get cpu infomation via the registry. After completing it, the manager wanted the 9x info as well. There is no clean way to get that info via the registry so I decided to hard code the info in a hash of hash of lists. Reason is that there are a few domains and he wanted the info for each domain. I am trying to call it in this fashion:
my %win9x = ( domain1 => { Test98 => [ "Windows 98", , 1, 233, 128], TestME => [ "Windows Me", , 1, 233, 64], Win981 => [ "Windows 98SR2", , 1, 600, 512], Win982 => [ "Windows 98SR2", , 1, 600, 512], WinME1 => [ "Windows Me", 1, , 600, 512], WinME2 => [ "Windows Me", 1, , 600, 512] } ); unless ($domain = shift) { @ARGV = Win32::DomainName or die "Unable to obtain the domain +name\n"; } foreach $domain (@ARGV) { print "\nDOMAIN:\t$domain\n\n"; AddWin9x{%win9x}; }
The sub routine will not work because it reports. Can't locate object method "AddWin9x" via package "DOMAIN1" (perhaps you forgot to load "DOMAIN1"?)
sub AddWin9x { my %hoh = shift or next;; my $computer; my $os; my $cpu; my $mhz; my $ram; my $sp; print "\n\nWindows 98//Me\n\n"; foreach {$hoh{$domain{$computer}}) { ($os, $sp, $cpu, $mhz, $ram) = $computer; printf ("%20s %3s %-15s %3s %4s %5s\n",$computer, $os, + $cpu, $mhz, $ram); } }
The sub I have not tested out because I have not gotten that far. Sorry but my head hurts from banging it on the desk! Thanks for any suggestions!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to pass a hash of hash of lists
by tstock (Curate) on Mar 14, 2002 at 01:59 UTC | |
by Marza (Vicar) on Mar 14, 2002 at 03:36 UTC | |
|
Re: Trying to pass a hash of hash of lists
by Juerd (Abbot) on Mar 14, 2002 at 08:26 UTC | |
by tye (Sage) on Mar 14, 2002 at 17:39 UTC | |
by Juerd (Abbot) on Mar 14, 2002 at 17:52 UTC | |
by tye (Sage) on Mar 14, 2002 at 18:13 UTC | |
by Juerd (Abbot) on Mar 14, 2002 at 18:57 UTC |