http://www.perlmonks.org?node_id=1026737


in reply to How can one initialize the scalar $reg_no in hash element?

while (<Rdata.txt>) { my ($name, $age, $reg_no )=split":"; $studentsDB {$reg_no}={Name => $name, # Line 52: uninitialized reg_ +no Age => $age,};}
Are you trying to read lines from the file named Rdata.txt? If so, that won't do it. You probably want to open that file first. I think your warning message occurs because split operates on $_ in your code, and $_ is probably undefined (or at least does not have 3 ":"'s in it.

Tips from the Basic debugging checklist:

Replies are listed 'Best First'.
Re^2: How can one initialize the scalar $reg_no in hash element?
by supriyoch_2008 (Monk) on Apr 03, 2013 at 01:57 UTC

    Hi toolic,

    Thanks for the suggestions and for providing the links to Basic degugging checklist.

    With kind regards