in reply to counting occurances
my $count; $count += tr/FIL/FIL/ while <DATA>; print "F, I, and L occurred $count times.\n"; __DATA__ FDIELSIGCOXLSAGICK\n
Update:
This approach will give you a combined total count for all the items you're counting. If you want an individual count for each thing you're counting, with the ability to easily add or subtract items from the count list, see my followup post. Therein you will find two examples that both work well. The first (which I prefer) uses tr///, and the second uses index. I think you'll find those solutions to be much closer to what you need.
Hope this helps!
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: counting occurances
by imlou (Sexton) on Sep 19, 2003 at 19:29 UTC | |
by davido (Cardinal) on Sep 19, 2003 at 20:03 UTC | |
by shenme (Priest) on Sep 19, 2003 at 20:16 UTC | |
by shenme (Priest) on Sep 19, 2003 at 21:40 UTC | |
by qmole (Beadle) on Sep 19, 2003 at 20:03 UTC |