in reply to Find number of short words in long word
The =()= 'operator' should do:
Big Update:my $count =()= 'abracadabra' =~ /br/g; print "Found $count instances\n" # prints Found 2 instances
Or extract the one active line that is left in there.sub countOverlappingMatches { my $stringRef = shift; #Likely to be huge, don't make a copy my $patternRef = shift; my $count =()= $$stringRef =~ /(?=$$patternRef)/g; return $count; } print countOverlappingMatches(\'abrabrabrabra', \'rabra'); # 3
for my $pattern (@listOfPatterns) { my $count =()= $string =~ /(?=$pattern)/g; # Play with $count }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find number of short words in long word
by ikegami (Patriarch) on Jul 14, 2009 at 20:42 UTC | |
|
Re^2: Find number of short words in long word
by psini (Deacon) on Jul 14, 2009 at 20:43 UTC | |
by moritz (Cardinal) on Jul 14, 2009 at 20:50 UTC | |
by AnomalousMonk (Archbishop) on Jul 14, 2009 at 23:37 UTC | |
by sedm1000 (Initiate) on Jul 14, 2009 at 20:54 UTC | |
by SuicideJunkie (Vicar) on Jul 14, 2009 at 22:50 UTC |