if ( $ENV{'REQUEST_URI'} =~ m|\A/shop(/.*)$| ) { my $url = $1; $url .= '/' if $url !~ m|/$|; $sth = $dbh->prepapre("..."); # ... }