Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Count multiple pattern matches

by zejames (Hermit)
on Dec 07, 2004 at 10:18 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://412873]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found