Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Using Split to load a hashby davido (Cardinal) |
on Aug 19, 2006 at 15:43 UTC ( [id://568364]=note: print w/replies, xml ) | Need Help?? |
Yes, you can use split for that. First, open the file. Next, iterate over its content. Chomp the line. If the remaining line is empty, next to the next line (this is just a precaution). Assuming the line isn't blank, split it on comma, assigning the results to two lexical variables. Then use one variable as the key, and one as the value in adding an element to your hash. Finally, close the file. Let us know which part of that task has you stumped. Dave
In Section
Seekers of Perl Wisdom
|
|