stretch has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to get a html utility script I found on the site to run. section of code containing unable to parse error
if($content=~m|<BODY.*?>(.*?)</BODY>|si) { $content = $header_html . $1 . $footer_html; $content =~ s|%title%|$title|; &save_file("$fullpath",$content); print "Completed\n"; } else{ print "Couldn't parse\n"; }
I defined $header_html and $footer_html.
Pointing to the actual html header and footer files.
my $header_html= 'C:/My Documents/carlist/carlist_test/template/cchead +er.html'; my $footer_html= 'C:/My Documents/carlist/carlist_test/template/ccfoot +er.html';
stops with a 'unable to parse' error at line
$content = $header_html . $1 . $footer_html;
Thanks, Stretch

Replies are listed 'Best First'.
Re: 'unable to parse' error
by katgirl (Hermit) on Aug 15, 2002 at 08:00 UTC
    How about if you try what I've written below. What I've done is open the file first, then assign the contents to your header or footer. I've also put in $! after "couldn't parse" so we can see exactly what is going wrong.

    Can you try that, and tell me what it says?

    open (TXTFILE, "C:/My Documents/carlist/carlist_test/template/ccheader +.html"); $header_html = <TXTFILE>; close(TXTFILE); open (TXTFILE, "C:/My Documents/carlist/carlist_test/template/ccfooter +.html"); $footer_html = <TXTFILE>; close(TXTFILE); if($content=~m|<BODY.*?>(.*?)</BODY>|si) { $content = $header_html . $1 . $footer_html; $content =~ s|%title%|$title|; &save_file("$fullpath",$content); print "Completed\n"; } else{ print "Couldn't parse: $!\n"; }
Re: 'unable to parse' error
by stretch (Novice) on Aug 15, 2002 at 14:05 UTC
    obliged Katg, I inserted edited code as suggested and received:
    global symbol "$header_html" requires explicit package at...

    line that I inserted your edited suggestion.
    Samething for  "$footer_html" I'm reading about what 'global packag' is Lemay's SAMS and Oreilly's 2rd ed books now.
    any other ideas?
    Stretch