P
Pat McDonnell
Hello -
I'm working on a script in which the user provides a path, and the script
does something based on that path. I want to develop some type of
association between paths, and actions to perform. For instance, take the
following:
Path Action
----------------------
/home &home()
/home/luser &luser()
/home/luser/abc &luserabc();
So, if the user passes /home/luser, &luser would be executed. If the user
passes /home/luser/xyz, &luser would still be executed, as it is the most
specific match for that path. If /home/anotheruser is passed, &home would
be executed, as that is the most specific match. Does this make sense?
So, my question is, is there any type of data structure/module that is best
for this? I could hack something together with regex's and loops easily
enough, but I was hoping there would be something "cleaner." I've looked
at a trie, but that seems to be the opposite of what I want. Thanks.
I'm working on a script in which the user provides a path, and the script
does something based on that path. I want to develop some type of
association between paths, and actions to perform. For instance, take the
following:
Path Action
----------------------
/home &home()
/home/luser &luser()
/home/luser/abc &luserabc();
So, if the user passes /home/luser, &luser would be executed. If the user
passes /home/luser/xyz, &luser would still be executed, as it is the most
specific match for that path. If /home/anotheruser is passed, &home would
be executed, as that is the most specific match. Does this make sense?
So, my question is, is there any type of data structure/module that is best
for this? I could hack something together with regex's and loops easily
enough, but I was hoping there would be something "cleaner." I've looked
at a trie, but that seems to be the opposite of what I want. Thanks.