Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: uninitialized value in numeric eq (==)

by rdfield (Priest)
on Nov 11, 2003 at 11:45 UTC ( [id://306158]=note: print w/replies, xml ) Need Help??


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

  • Why put quotes around the numbers 1 and 2?
  • Why use a prototype?
  • have you checked the value of $schema_in?

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://306158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-25 21:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found