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

I am taking over a fairly large CGI project that has several bugs in it. I believe that all these bugs are the result of not ensuring that the variables actually had data in them before using them.

I am in the process of moving the system to "use strict;" but, that will take some time because of the length of the code and I need a quick fix for some of these errors.

Is there a way that I can find all the variables that are used and the values assigned to them, including the function that they are being used in? Because of the nature of how the program was developed, I don't have an easy way of visually finding each variable being used.

Replies are listed 'Best First'.
Re: finding null vars
by Anonymous Monk on Mar 25, 2003 at 23:20 UTC

    "use strict" is not enough. Try

    #!/usr/bin/perl -w use strict; # your code follows

    And the Perl compiler should tell you if a variable is not initialized

Re: finding null vars
by JamesNC (Chaplain) on Mar 25, 2003 at 23:23 UTC
    Monks usually like to see the following info:
    1. What is your OS?
    2. Some CODE
    3. What did you try?

    Having said that... and without anything to look at, most of the CGI errors you seem to be talking about are because your form may not be returning anything or aren't being initialized and are undefined. Are you connecting to a Database or other module that is failing because your parameter list is incomplete? Who knows.... You need to supply more info... like what your code is doing.. which modules are you using? What version of Perl?
    try use Warnings; and use Strict;

    perldoc perldebug
    I would suggest that you purchase the Camel and Llama Books on Perl by Merlyn and Perl's Author Larry Wall at ORE. These folks won't answer questions without some real effort on your part. :-(