For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > April 2005 > Question about "warn"









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Question about "warn"
Martin Kissner

2005-04-27, 8:57 pm

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

--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114
,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,
110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
Gunnar Hjalmarsson

2005-04-27, 8:57 pm

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


<snip>

> use HTML::Template;


<snip>

> $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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
J. Gleixner

2005-04-27, 8:57 pm

Martin Kissner wrote:

> 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.
Martin Kissner

2005-04-27, 8:57 pm

Gunnar Hjalmarsson wrote :
> Martin Kissner 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

--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114
,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,
110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
Martin Kissner

2005-04-27, 8:57 pm

Gunnar Hjalmarsson wrote :
> Martin Kissner 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

--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114
,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,
110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com