CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [reverend] help with use all cells of array in regex: Edit Log



7stud
Enthusiast

Dec 2, 2009, 5:06 PM


Views: 2828
Re: [reverend] help with use all cells of array in regex


Code
use strict; 
use warnings;
use 5.010;

my $str =<<ENDOFSTR;
hello, monkey
bye; monkey
bye, dog;

cat end
ENDOFSTR

my @arr = ('monkey', 'cat');
my $count = 0;

for (@arr) {
$count++ while ($str =~ /[,;]\s+$_/g) ;
}

say $count;

--output:--
3



(This post was edited by 7stud on Dec 2, 2009, 5:07 PM)


Edit Log:
Post edited by 7stud (Enthusiast) on Dec 2, 2009, 5:07 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives