Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Error using HTML::Template

by swngnmonk (Pilgrim)
on Dec 11, 2003 at 15:21 UTC ( #314049=note: print w/ replies, xml ) Need Help??


in reply to Error using HTML::Template

I see two errors - one is an error in your code (copy/paste from improperly formatted POD on your end), the other is an actual typo in the POD.

Looking at the POD on CPAN, the line reads:

# send the obligatory Content-Type and print the template output print "Content-Type: text/html\n\n", $template->output;

So it's "print", not "output print". But there is a typo in the POD - that comma before $template->output; should be a period (string concatenation).

print "Content-Type: text/html\n\n". $template->output;

Or, if you're familiar with C, you could also write it in a more recognizable form:

print sprintf("Content-Type:text/html\n\n%s",$template->output);

No difference, really, but sometimes people find it easier to read the latter.


Update: Ok, so I'm wrong about the second bug - I'll plead ignorance to printing in LIST form. That being said, based on the original post, I think a code copy &paste went badly, and that's why you're getting the strange error messages.

PS - and yes, you could just use printf, but you'll get far more use out of sprintf in the long run. :)


Comment on Re: Error using HTML::Template
Select or Download Code
Re: Re: Error using HTML::Template
by !1 (Hermit) on Dec 11, 2003 at 15:33 UTC
    But there is a typo in the POD - that comma before $template->output; should be a period (string concatenation).

    Why?

    #!/usr/bin/perl -l print 1,2,3; $,=$"; print "this","works"; __END__ 123 this works

    This is the print LIST form that is mentioned in perldoc -f print.

Re: Re: Error using HTML::Template
by ctilmes (Priest) on Dec 11, 2003 at 15:41 UTC
    I wouldn't bother with print sprintf(...).. just use printf.
Re: Re: Error using HTML::Template
by Anneq (Vicar) on Dec 11, 2003 at 19:54 UTC

    swngnmonk,

    The comment and line of code are correct in my script. It could be that it showed up incorrectly on the node because I didn't use code tages. Thanks to Allolex pointing that out. It looks fine on my screen because I am using small fonts in my CSS.

    I thought that the comma could be problem too, so I tried using the concatenation operator and also tried using two print statements but to no avail.

    I'm a newbie to programming and web pages so I think using C is out for me right now. Too steep a learning curve.

    Thank you for taking your valuable time to respond.

    Much appreciated,

    Anne

    Anneq

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://314049]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2015-07-04 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls