Deepak Mallya wrote: > Hi, > When I try to use complex data structures I get an error saying > Use of uninitialized value in string at C:\Documents and > Settings\deepm\My Documents\practice.pl line 29, <FILE> line 1. > > The line of code is as follows:- > for ($i=0;$i<=$#terms;$i++) > { > > $wordlistref->{$terms[$i]}->{"postingsref"}->{"$doc"}->{"d1"}->{$termfreq}++; > } > > Can anyone help me on this..Do I need to initialise every single hash > ???cant I use it as above
Depends what you mean by "initialize". If you mean create the entry, then no, Perl does this for you (it's called auto-vivification). If you mean actually give the entry a defined value before using it, then yes. In the example above the error message says "uninitialized value in string". Note the "string" not "hash" part of the warning. I suspect your $doc var is undefined. It's the only thing I can see that is a string. -- Michael Peters Developer Plus Three, LP