in reply to Weird un-tainting problem.
Are you *positive* the match succeeds? I'm not. Throw an if clause in there:
my $realm; if ($ENV{SCRIPT_FILENAME} =~ m!${docroot}(.*?)/!) { $realm = $1; } else { print "Realm ($realm) is really wrong.\n"; } [download]