Question about "warn"

M

Martin Kissner

Hello together,

I had some trouble with HTML::Template, do I added some "warn" commands
to my script to find the error.

After I had fixed my script I still got warnings in the error log of my
webserver.
Why do I get these warnings also when the command before "or warn ..."
was successfuly executed?

Here is a short sample:

----- start -----

#!/usr/bin/perl
use strict;
use warnings;

use HTML::Template;

print "Content-Type: text/html\n\n";

my $template = HTML::Template->new(filename =>
"template.html");

my $title = "My Title";

##### here comes the questionable line ######
$template->param(TITLE => $title) or warn ("param failed\n");

print $template->output;

----- end -----

Thanks in advance
Best regards
Martin
 
G

Gunnar Hjalmarsson

Martin said:
Why do I get these warnings also when the command before "or warn ..."
was successfuly executed?

use HTML::Template;

$template->param(TITLE => $title) or warn ("param failed\n");

Does the HTML::Template POD say that the param() method always returns a
true value at success and a false value at failure? If not, that way to
check for success is not correct.
 
J

J. Gleixner

Martin said:
Why do I get these warnings also when the command before "or warn ..."
was successfuly executed?
##### here comes the questionable line ######
$template->param(TITLE => $title) or warn ("param failed\n");

Look at what param() returns.

Seems like you might also want to read about how "or" works, and in what
case(s) would the warn be called.
 
M

Martin Kissner

Gunnar Hjalmarsson wrote :
Does the HTML::Template POD say that the param() method always returns a
true value at success and a false value at failure? If not, that way to
check for success is not correct.

Thanks for that hint. I was not conscious of this, although, of course,
it makes sense.

Best regards
Martin
 
M

Martin Kissner

Gunnar Hjalmarsson wrote :
Does the HTML::Template POD say that the param() method always returns a
true value at success and a false value at failure? If not, that way to
check for success is not correct.

Thanks for that hint. I was not conscious of this, although, of course,
it makes sense.
Thanks also to J. Gleixner.

Best regards
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top