Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 chilling in the Monastery: (3)
As of 2014-09-20 00:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls