Check if given string matches one of set of prefixes, effectively
问题 What algorithm to use to check if a given string matches one of set of prefixes, and which prefix from that set? Other variation: given path and a set of directories, how to check if path is in one of set of directories (assuming that there are no symbolic links, or they do not matter)? I'm interested in description or name of algorithm, or Perl module which solves this (or can be used to solve this). Edit Bonus points for solution which allow to effectively find 'is prefix of' relation