Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Count multiple pattern matches

by zejames (Hermit)
on Dec 07, 2004 at 10:18 UTC ( #412873=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    print $re;
    __DATA__
    (?-xism:(?-xism:(?:(foo))(?{$result{$_}++}))|(?-xism:(?:(bar))(?{$resu
    +lt{$_}++})
    )|(?-xism:(?:(12345))(?{$result{$_}++}))|(?-xism:(?:(abcd))(?{$result{
    +$_}++})))
    
  2. or download this
    my $data = "foofdsfdsbar";
    my @matches = 
        $data =~ m/(foo)(?{print "($1,$2,$+)"})|(bar)(?{print "($1,$2,$+)"
    +})/g;
    __DATA__
    (foo,,foo)(,bar,bar)
    
  3. or download this
    #!/usr/bin/perl
    
    ...
    
    print "$_: $result{$_}\n" for @keywords;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412873]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2018-06-23 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (125 votes). Check out past polls.

    Notices?