Many thanks to those who shared their knowledge. I had a feeling that there would be an elegant solution to my problem, but I was having no luck figuring it out.
For reference, where before my code was:
$Pcc++ while $sequence =~ /cc/gi;
..it is now:
$Pcc++ while $sequence =~ /c(?=c)/gi;
I now know what a zero-width positive look-ahead assertion is! For anyone who's also struggling with this, read this page (the "Extended Patterns" section) and compare the different types of assertion:
http://www.perldoc.com/perl5.8.0/pod/perlre.html
My program is now counting *all* occurrences of "cc", including those that overlap.
Looking back at the "/cc/" pattern, it seems obvious that it won't work, but only now that I understand how the matches are found. I've read through a number of 'Introductions to regular expressions in Perl' type documents for this coursework, and I found no indication that my initial pattern wouldn't work as I imagined. I'm not sure if that was my misunderstanding of the material, or a limitation of the documentation (in not pointing out the limitation of the "/cc/" pattern). It's probably the former.
Anyway, I'm rambling again. Thanks for the help everyone.
Regards,
Henry.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>