my $path = "/dirpath/*"; my $word = "foobar"; my $times = grep /\Q$wordhere/, glob $path; print "total = $times\n";