On Thu, Oct 24, 2002 at 10:43:50AM -0700, naveen prabhakar wrote:
> Hi,this might be a really silly question.

I might be feeding you a bunch of fish, rather than pointing you to
documentation, so we both might be silly.

 
> what values are considered as uninitialized.how can I avoid this error.

undef is considered uninitialized.  A variable's value is, by default,
undef.  You receive the warning whenever Perl has to convert undef to a
string or a number; for example, if you compare it to another value, or if
you add it, etc.

To avoid the error in general you should do one of two things:

    1) Initialize your variable to something other than undef, and never
       assign undef to it.

    2) Test your variable with defined before attempting to use it.

You can also turn off warnings, either globally or locally, but I would not
suggest relying on that.  The warning is a diagnostic to let you know you
haven't handled something properly, you shouldn't try to avoid it to fix the
problem.

 
> what does chunk 299 mean.the chunk number remains the same for a series of
> such error statements.I have just tried to read from a file into an array
> of records and a hash of records

The "<DB2> chunk 299" part tells you that the filehandle DB2 was at chunk
299 when you received the error.  This is to help you determine if there was
a parsing error with that specific chunk.  A chunk is whatever is read by a
<DB2> operation ($foo = <DB2>, while (<DB2>), etc.); usually it's a
line, but you can redefine $/ (the input record seperator, normally
newline), thus it's "chunk" and not "line".

 
> Use of uninitialized value at ./tablecomp.pl line 780, <DB2> chunk 299
> 
> the line at 780 is.
> 
> if($db2array->[$i]->{$db2key} ne $raimah->{$id}->{$db2key})

Either $db2array->[$i]->{$db2key} or $raimah->{$id}->{$db2key} was
undefined.  You can know this because perl gives different warnings for the
different parts of your data structure.

For example, if $i was undefined, you would've been given the warning:

    Use of uninitialized value in array element ...

If $db2key or $id was undefined you would've been given the warning:

    Use of uninitialized value in hash element ...

So, by process of elimination, it must be $db2array->[$i]->{$db2key} or
$raimah->{$id}->{$db2key}.  This is all assuming you have a recent version
of Perl that does, indeed, give out these specific warnings, and that my
logic is correct.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to