Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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?
LanX is right-handed :(
Happy-the-monk hands LanX a treat of ambidextrosis.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2018-02-19 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (264 votes). Check out past polls.

    Notices?