|Perl: the Markov chain saw|
How To Print Single Element From Nested Hashes?by jdlev (Scribe)
|on Sep 10, 2013 at 21:23 UTC||Need Help??|
jdlev has asked for the
wisdom of the Perl Monks concerning the following question:
Hi again guys. I really am sorry about asking so many questions, but really appreciate the help...
So right now, in my program I have basically have a ton of data that repeats itself, and I'm trying to condense it to speed it up. It get's the same stats on every player. PlayerID, Position, Salary, PointsPerGame...I'm trying to figure out how to explain this, so bear with me because I'm utterly confused...
I have a foreach loop that iterates through a DBI produced Hash. It does it based on the players position. So basically, it looks kind of like this:
Now I know I should be able to condenses 10 foreach loops into a single one, but how? Should I use some type of subroutine? Dynamic Variables fed by arrays?
How would I make dynamic variables where on the iterations through the formula, the variable name is updated. So for instance, the first time through, the variable would be set to $QB1, the second time through, it would be set to $QB2...and so on?
Thanks for any help once again :)
UpdateLet's say a hash has the following structure:
What syntax would I use to pull out the 'Name' for '114'? to have the program return 'Melissa'?
I love it when a program comes together - jdhannibal