|We don't bite newbies here... much|
Re^2: why use a hash instead of an arrayby 5mi11er (Deacon)
|on Jun 11, 2013 at 21:18 UTC||Need Help??|
For a person just learning perl, your example code is quite obtuse. You should at least attempt to explain how your code actually works.
I'd do it for you, but need to leave work now...
Update: since no one else has yet done so, and I'm back at work now, I'll try:
So, the $/ floating all over the above post is simply a special variable holding, by default, a "new line" character, ie. "\n". The first section
simply reads in the data, and for every word in the DATA section, increments the hash table entry for that word. It would be more clear to beginners if it were written thusly:
Once you have the data read in, you'll have the following data structure:
2teez then uses more advanced perl to essentially do the following:
From these two beginner friendly examples, it should be pretty easy to do 2teez's 3rd challenge which is to print out the data structure I gave above.