in reply to Trouble with path syntax

I haven't seen yet what the value of $file is before that code is executed. Add some prints to help debug, like:
print "Start: \$file = $file\n"; my($thebase) = ($file =~ /(.*)\/[^\/]+/); print " \$thebase = $thebase\n"; my($html,$html2); print "Just before test to see if \$file exists\n"; if (!-e $file){ print "$file does *NOT* exist!\n"; $thebase =~ s/\/[^\/]+$/\/default/; print "\$thebase *AFTER* substituting default = $thebase\n"; ### the rest of your code ###
Those will help figure out exactly what your code is doing. Once we see the results of that it will be easier to offer help.