#! perl use strict; use warnings; my $target = 'kitten'; my $string = do { local $/; ; }; $string =~ s/\n//g; my $count = () = $string =~ /\Q$target/g; print "The target string '$target' occurs $count times in the file\n"; __DATA__ sushikitten ilovethekit tensushithe kittenisthe #### 14:28 >perl 1474_SoPW.pl The target string 'kitten' occurs 3 times in the file 14:28 >