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

Re: How to count substrings in an array?

by BrowserUk (Pope)
on Feb 03, 2013 at 08:16 UTC ( #1016802=note: print w/replies, xml ) Need Help??


in reply to How to count substrings in an array?

my $count = 0; $count += map /$substring/g, @array;

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: How to count substrings in an array?
by AnomalousMonk (Chancellor) on Feb 03, 2013 at 11:16 UTC

    ... and you don't even need the '+' on the  += operator:

    >perl -wMstrict -lE "my $s = 'abababa'; my $t = 'aba'; ;; my $c = map /(?=$t)/g, qw(abababa ababa); say $c; " 5
      and you don't even need the '+' on the += operator:

      Of course I don't. Much nicer!


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016802]
help
Chatterbox?
Corion had a meeting with some startup today. They have a very interesting DB proxy product, but their tech stack is really, really weird. They use the Pg wire protocol but not the Pg libraries to handle it. They support Pg SQL syntax, but don't use ...
[Corion]: ... the Pg parser (or so they claim).
[Corion]: Also, they rolled their own user management instead of supporting LDAP for user/role management, but that just shows that they're new in the enterprise market :)
Corion also just now realizes they didn't leave business cards.
[erix]: can you drop a name? :)
[karlgoethebier]: Corion: "...didn't leave business cards" Those guys came from Muränia?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2018-04-19 12:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?