Substring count for Perl