Phil Ritchie wrote: > I'm trying to count occurrences of patterns using > > $_ = 'ababcdabcd'; > while ($_ =~ m/\Gab/gc) > { > $num++; > } > while ($_ =~ m/\Gcd/gc) > { > $num++; > } > print $num; > > But it doesn't work. I have a feeling that I need to employ the pos > function somewhere but have no idea where or how.
Here's mine: use strict; my $A = 'abcabc abc ab d'; my $cnt = 0; $cnt++ while $A =~ /ab/g; print $cnt, "\n"; __END__ -- ,-/- __ _ _ $Bill Luebkert ICQ=162126130 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs