Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 perusing the Monastery: (5)
As of 2014-10-25 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls