Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

'unable to parse' error

by stretch (Novice)
on Aug 15, 2002 at 05:31 UTC ( [id://190307]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://190307]
Approved by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found