#!/perl/bin/perl -w use strict; my $str = 'ffggffffhhffii'; my $searchstr1 = 'ff'; my $searchstr2 = 'ee'; my @ary1 = $str =~ /$searchstr1/g; my @ary2 = $str =~ /$searchstr2/g; printf qq("%s" matches "%s" %d times.\n), $searchstr1, $str, scalar @ary1; printf qq("%s" matches "%s" %d times.\n), $searchstr2, $str, scalar @ary2; __OUTPUT__ "ff" matches "ffggffffhhffii" 4 times. "ee" matches "ffggffffhhffii" 0 times.