#! perl #! usr/bin/local/perl $file = shift; $pattern = shift; open(MAT, "<$file") or die "bad file name"; $text = ; while($text =~ /\Q$pattern\E/g) { $x += 1; } print "found $x matches\n"; close(MAT);