dmtelf has asked for the wisdom of the Perl Monks concerning the following question:
Can you do something like the below in one line instead?for $clipnum(0 .. $noofclips-1) { if ($file{$clipnum}{FILETYPE} eq "Menu") { $menucount++; if ($file{$clipnum}{VOICEOVER} eq "No") { $menunvocount++; } else { $menuvocount++; } } if ($file{$clipnum}{FILETYPE} eq "Video") { $videocount++; if ($file{$clipnum}{VOICEOVER} eq "No") { $nvocount++; } else { $vocount++; } } }
$menucount = (all keys in hash that equal) ($file{$clipnum}{FILETYPE} +eq "Menu" && ($file{$clipnum}{VOICEOVER} eq "No")
I know how to find the total number of keys in a hash - $num_keys = scalar keys %file; but not how to make it do that if & only if certain conditions are met.
thanks for your help in advance
dmtelf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Keeping a count of matches in a hash that satisfy more than 1 condition
by lhoward (Vicar) on Jul 19, 2000 at 17:35 UTC | |
|
(jjhorner)Keeping a count of matches in a hash that satisfy more than 1 condition
by jjhorner (Hermit) on Jul 19, 2000 at 17:42 UTC | |
|
Re: Keeping a count of matches in a hash that satisfy more than 1 condition
by eduardo (Curate) on Jul 19, 2000 at 17:39 UTC | |
by jjhorner (Hermit) on Jul 19, 2000 at 17:44 UTC | |
by eduardo (Curate) on Jul 19, 2000 at 17:49 UTC | |
|
Re: Keeping a count of matches in a hash that satisfy more than 1 condition
by turnstep (Parson) on Jul 19, 2000 at 19:26 UTC | |
|
Re: Keeping a count of matches in a hash that satisfy more than 1 condition
by barndoor (Pilgrim) on Jul 19, 2000 at 19:32 UTC |