Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Count number of occurrences of a substr

by toolic (Bishop)
on Sep 28, 2011 at 18:47 UTC ( [id://928387]=note: print w/replies, xml ) Need Help??


in reply to Count number of occurrences of a substr

This is a FAQ (see perlfaq4):
perldoc -q count
use warnings; use strict; my $str = "thisthis"; if ( my $n = () = ($str =~ m/this/g) ) { print qq{Found $n occurrence(s) of "this"\n}; } __END__ Found 2 occurrence(s) of "this"
Perl Idioms Explained - my $count = () = /.../g

Log In?
Username:
Password:

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

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

    No recent polls found