powerhouse has asked for the wisdom of the Perl Monks concerning the following question:

Ok, I'm getting this error:


Here is line 61:


Since that is the beggining of the string, here is the whole string:
$page_content = qq~ $message <font size="1" face="Verdana, Arial, Helvetica, sans-serif"> Thank you,$nname_ws_b for visiting $co_name! We are re-designing our site\. Sorry if you have found it before we are finished!<br /> <br /> <br /> <br /> <table border="0" align="center" cellpadding="2" cellspacing="2"> <tr valign="middle"> <td align="left"><font size="1"> $co_name now accepts </font /></td /> <td align="left"> <A HREF="$url?pg=why_change$inc_sess_id" onclick="window\.open('$url?p +g=new_billing','BILLING','toolbars=yes,location=yes,resizable=yes,sta +tus=yes,scrollbars=yes')"> <IMG SRC="$imageurl/graphics/New_logo.gif" BORDER="0" /></A /> </td /> </tr /> </table /> </font /> <p>&nbsp;</p /> <p>&nbsp;</p /> ~;

What is wrong with that? How can I fix it?

Thanks,
Richard

Replies are listed 'Best First'.
Re: Use of uninitialized value??
by Paladin (Vicar) on Jan 28, 2003 at 04:28 UTC
    One of the variables in your string is uninitialized. Check where each one is defined and/or assigned to and make sure they are all being set properly. Perhaps show us the rest of the code and someone might be able to spot which one is causing the problem.
      Thank you. I figured it out, based on what you said. I had not checked to make sure a field was "defined" before I used it to do a if statement.

      Now I am having to go through TONS of lines of different pages to see where else I did that :o(

      Now I know. THANK YOU!

      thx,
      Richard

        Keep in mind that the "Use of uninitialized..." message is only a warning. Strictly speaking you don't have to fix it but naturally it's best to do so.

        The way I commonly fix this is to do:

        if ($variable and $variable eq 'value') { # do something # ... }

        This uses the "short circuit" property of and to check whether the variable is defined before it checks the value. I'm sure some of the more experienced monks can enlighten us as to whether or not this is good practice.

        --
        Grant me the wisdom to shut my mouth when I don't know what I'm talking about.

Re: Use of uninitialized value??
by artist (Parson) on Jan 28, 2003 at 04:45 UTC
    When you activate warning with 'use warning' or '#!perl -w' it gives you this message. In order to identify put 'use strict;' in your program and it will tell that which variable is not initialized or used only once. For more information see how to use strict.

    Artist