Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: This should be easy: counting letters in a string

by inman (Curate)
on Jan 31, 2006 at 11:36 UTC ( #526714=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
        eval "\$count = \$string =~ tr/$a//";
        print "$count\n";
    }
    
  2. or download this
    $count = $string =~ s/$a//g;
    
  3. or download this
    my %count;
    $count{$_}++ foreach split //, $string;
    print "$count{$_}\n" foreach (@letters);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://526714]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-07-12 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (239 votes), past polls