I am not familar with the module that you are using, but some general comments on techniques to deal with undef vars may be of interest. I personally strive to write code that just doesn't produce warnings rather than restricting the logging level or ignoring them.

Sometimes when working strings, I use Perl's ||= operator to make sure that some string variable is defined to at least "" (null string). This can also be used to set a null string to some default value! The below code demo's this special ||= operator.

Example:
(a) shows how to avoid undef.
(b) shows a "gottcha" if the string is "0", you probably won't get the result intended! So you have to decide if "0" is some reasonable value or not and if so, handle that differently.
(c) shows a case case where the value of "xyzzy" remains unchanged. Perl is returning the value of "xyzzy" without evaluating the "" part. This is not a simple "True/False" value. The ||= operator is also very fast.
(d) shows setting the default "after the fact". Often you set a var to some default value and then override the default in a subsequent statement. However sometimes (like maybe dealing with a regex pattern match that fails), it is more convenient to have a syntax that says "hey if it didn't work, then this is the default string that I wanted" when result was undef or null string.
(e)shows a more complex example, I took this from one of my programs (of course "var names have been changed to protect the innocent"). I did it this way to simplify the thing that outputs this structure. I could have chosen not to create a value for {'key2'} but then I'd have to do something on the output end to figure out that this value didn't exist.

#!/usr/bin/perl -w use strict; my $a = undef; print "a=$a\n"; #warning undef var ! $a ||= ""; # $a = $a || ""; print "a=$a\n"; #no warning "" null string my $b= "0"; #gottcha with string of "0" print "b=$b\n"; $b ||= ""; print "b=$b\n"; #sets b to "" (changes "0" to "") my $c = "xyzzy"; $c ||= ""; print "c=$c\n"; #c still "xyzzy" !! my $d = ""; $d ||= "default"; print "d=$d\n"; #d is "default" my %hash; my $e = ""; $hash{'key1'}{'key2'} = $e ||= "--"; print "$hash{'key1'}{'key2'}\n"; #prints "--" __END__ Output: Use of uninitialized value $a in concatenation (.) or string at C:\TEM +P\scratch.pl line 5. a= a= b=0 b= c=xyzzy d=default --

In reply to Re: How to avoid warnings in HTML::Template::Pro? by Marshall
in thread How to avoid warnings in HTML::Template::Pro? by ganeshk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.