in reply to problem with if condition

. binds less strong than ~= does. Using double quotes or parentheses makes your code work. Change

&& ($DOCROOT.$uri !~ /\/$/)) {
to
&& ("$DOCROOT$uri" !~ /\/$/)) {

or, even better, construct a variable $local_path from $DOCROOT and $uri. Note that your webserver will allow access to directories outside of $DOCROOT if $uri contains for example ../../.

Replies are listed 'Best First'.
Re^2: problem with if condition
by agn (Initiate) on Jul 13, 2009 at 09:53 UTC

    Doh! I feel stupid for not knowing that. I should really read about the precedence rules. Thanks a bunch. I've really been frustrated with this. Also I didn't catch this while running it through the debugger (perl -d).

    About .. traversals, I sanitise $uri before passing it to the above snippet.

    -agn