Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Keep It Simple, Stupid
 
PerlMonks  

Re: How can one initialize the scalar $reg_no in hash element?

by toolic (Chancellor)
on Apr 02, 2013 at 16:44 UTC ( #1026737=note: print w/ replies, xml ) Need Help??


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:


Comment on Re: How can one initialize the scalar $reg_no in hash element?
Download Code
Re^2: How can one initialize the scalar $reg_no in hash element?
by supriyoch_2008 (Scribe) 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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2014-04-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls