Is it true that the pattern matching operation $foo=~/$user_variable/ is unsafe?

0
Posted

Is it true that the pattern matching operation $foo=~/$user_variable/ is unsafe?

0

A frequent task for Perl CGI scripts is to take a list of keywords provided by the remote user and to use them in a patttern matching operation to fetch a list of matching file names (or something similar). This, in and of itself, isn’t dangerous. What is dangerous is an optimization that many Perl programmers use to speed up the pattern matching operation. When you use a variable inside a pattern matching operation, the pattern is recompiled every time the operation is invoked.

Related Questions