Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Faster way to do this?

by fishmonger (Chaplain)
on Nov 12, 2015 at 16:30 UTC ( [id://1147586]=note: print w/replies, xml ) Need Help??


in reply to Faster way to do this?

my $string = 'IIIIIIIIIIIMMMMMMMMMMMMOOOOOOOOOOOOMMMMMMMMMIIIIIIIII'; my $count = () = $string =~ /M/g; print $count;

You can also use the tr operator.

my $count = $string =~ tr/M//;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found