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

Re: Printing the count for regex matches

by jethro (Monsignor)
on Mar 10, 2009 at 01:32 UTC ( [id://749472]=note: print w/replies, xml ) Need Help??


in reply to Printing the count for regex matches

my @match; while (<DATA>) { my $string_found = $_; push @match,( $string_found =~ /(first_string|second_string|third_st +ring|fourth_string|fifth_string)/gm ); } print scalar @match," matches found: ",join ", ",@match, "\n";

Note that the var $string_found and the braces around the regex are superfluous

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-20 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found