Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 having an uproarious good time at the Monastery: (10)
As of 2015-07-08 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls