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

Re^4: counting inside the loop

by sarvan (Sexton)
on Jul 04, 2011 at 05:19 UTC ( [id://912591]=note: print w/replies, xml ) Need Help??


in reply to Re^3: counting inside the loop
in thread counting inside the loop

Hi,
$s='finding related pages finding on the world wide web'; my $count=$s=~ m/finding/g; print $count;

I expect the result as 2.. becus "finding" exists two times in $s. but the output is 1. Why??

thanks

Replies are listed 'Best First'.
Re^5: counting inside the loop
by Anonymous Monk on Jul 04, 2011 at 06:22 UTC

    It is because you don't know how to copy/paste

    The extra  ( ) = are required --- probably the worst syntax in all of perl, but its what you need if you have built-in regexes without objects, and you don't store matches in an array.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found