$count++ while $text =~ /$gene/g; # Count number of instances #### $count = () = $text =~ /$gene/g; #### my $p=0; ++$count while $p = 1+index( $text, $gene, $p );