-----Original Message----- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Monday, May 22, 2006 6:12 PM To: beginners@perl.org Subject: Re: Counting & arrays
Michael Gargiullo wrote: > It's been a while since I've used Perl and I need some help with a > multidimensional array. AKA a HASH :) You want a hash not an array :) > I have a file that I need to compile some stats on. > > I need to keep track of 'actions' and 'rules'. Yes, stats from a > firewall. > > Both 'actions' and 'rules' need to be dynamic so if a rule is added, > it's automatically dealt with. > > As I loop through the file I have both the current action and rule as a > variable. > > I've tried to store them several ways... > > > my @actionrule; > $actionrule[$action][$rule]++; $actionrule{$action}{$rule}++; > I need some kind of loop to extract the data. I also need to know what > the action and rule of each count is. for my $action (keys %actionrule) { print "Action is: $action\n"; for my $rule (keys %{ $actionrule{$action} }) { print "\tRule is: $rule\n"; print "\t\tand its count is: $actionrule{$action}{$rule}\n"; } } THANK YOU!! This works beautifully! I was pulling my hair out. Thanks again -Mike -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>