in reply to uninitialized value in numeric eq (==)

rdfield

Replies are listed 'Best First'.
Re: Re: uninitialized value in numeric eq (==)
by hmerrill (Friar) on Nov 11, 2003 at 13:37 UTC

    rdfield is right on the money.

    Pay attention to exactly what error message are trying to tell you - they are usually pretty easy to understand if you take a minute and really look at it. Notice

    Use of uninitialized value in numeric eq (==) at Creating_table_D.pl line 31. Use of uninitialized value in numeric eq (==) at Creating_table_D.pl line 35.
    Here's your code:
    sub create_table ($) { my($schema_in) = $_; if ($schema_in == "1"){ # offending line 1 my @tables = qw/A/; } if ($schema_in == "2"){# offending line 2 my @tables = qw/A B C/; }

    Notice in particular Use of uninitialized value. This probably means that $schema_in has *NO* value. As rdfield suggested, do some debugging - print out the value of $schema_in in subroutine 'create_table' to see if it is receiving the value you think it's receiving.

    Notice another thing - when doing a numeric comparison, you don't want to test using *string* "1" - you want to test using number 1 - without quotes around it. If you include the quotes and $schema_in contains a number, then perl will have to convert the string to a number and then do the numeric comparison.

    HTH.