in reply to Fetching 3 letters only

This should fit your requirements. You need to modify the $word variable.

Remember, when you need to count occurances, the hash is your friend.

use strict; my $word = 'abcdefabcdeab'; my ( %counters, $total ); while ( $word =~ /([a-c])/gi ) { $counters{$1}++; } foreach my $letter ( sort keys %counters ) { print "\n$letter: " . $counters{$letter}; $total += $counters{$letter}; } print "\nTotal: $total";
Produces:
a: 3 b: 3 c: 2 Total: 8
I hope this helps.

Replies are listed 'Best First'.
Re: Re: Fetching 3 letters only
by Anonymous Monk on May 23, 2003 at 19:38 UTC
    Wow, Thanks for all the answers. I will print all of them and use for future reference. Thanks again!