in reply to Re: regexp question
in thread regexp question

I have not tested either, but I think you should escape special characters in $string:
my $path =~ /^\Q$string\E  # the base string; '\tmp\foo', e.g.
               (\\.*)?     # optionally match a slash, etc.
               $           # match end of string
              /x;