in reply to Regex (counting) confusion :(

Take a look at what this outputs
# Not greedy pos() = 0; $string = q(xxxx); $count = ($string =~ s/[^x]*?/#/g); print qq($string $count), $/; __OUTPUT__ #x#x#x#x# 5
It looks to match the boundaries, and the beginning and end. They are matched because you are searching for 0 or more x's.

- Tom