Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: need help in extending the code

by Marshall (Prior)
on Jul 28, 2011 at 04:57 UTC ( #917184=note: print w/ replies, xml ) Need Help??


in reply to Re^2: need help in extending the code
in thread need help in extending the code

I'm not sure what you need. To count the number of occurrences of "finding" in a case insensitive way would require the /i switch for case_insensitive and then the /g switch to keep going globally.

There is a critter, called the goatse operator, "=()=" that will give the scalar count of the number of matches. You can read about it here: goatse operator. Or just look at the code and play with it..

!/usr/bin/perl -w use strict; my $x = "Finding fiNding fIndinG finding"; my $count = () = $x =~ /finding/ig; print "$count\n"; #prints 4


Comment on Re^3: need help in extending the code
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://917184]
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: (11)
As of 2015-07-07 16:05 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 (91 votes), past polls