in reply to Trouble with path syntax

My guess is the $file exists, so it never executes.
$thebase =~ s/\/[^\/]+$/\/default/;
So the base is /home/diamich/public_html/cgi-bin/linkmanage/templates. Then /master.htm is appended I assume.

Also if the file didn't exist, the regex would replace /templates with /default so you would end up with /home/diamich/public_html/cgi-bin/linkmanage/default/master.htm and not /home/diamich/public_html/cgi-bin/linkmanage/templates/default/master.htm, since your first regex strips off the file name.

Replies are listed 'Best First'.
Re: Re: Trouble with path syntax
by diamich (Initiate) on Aug 29, 2003 at 14:06 UTC
    You may be onto something here. A better shot of the code is:
    sub LoadTemplate { my($file) = @_; my($thebase) = ($file =~ /(.*)\/[^\/]+/); my($html,$html2); if (!-e $file){ $thebase =~ s/\/[^\/]+$/\/default/; } if (-e "$thebase/templates.old"){ open(TEMPLATE, "$file")||&DieNice("Opening: $file -- $!"); my $html = join('',<TEMPLATE>); close(TEMPLATE); }else{ open(TEMPLATE, "$thebase/master.htm")||&DieNice("Opening $theb +ase/master.htm: $!"); $html = join('',<TEMPLATE>); close(TEMPLATE); open(TEMPLATE, "$file")||&DieNice("Opening: $file -- $!"); $html2 = join('',<TEMPLATE>); close(TEMPLATE); $html =~ s/!INSERT!/$html2/i; }
    Still trying to figure out how to fix it.