|We don't bite newbies here... much|
Variables as a variable name... (I know you shouldn't but...)by 2mths (Beadle)
|on Aug 14, 2008 at 09:04 UTC||Need Help??|
2mths has asked for the
wisdom of the Perl Monks concerning the following question:
The 'problem' I'm trying to solve (probably trivial, but not for me):
A database query returns results like:
Ultimately I want to get this data into several arrays
Then I think I can do @data_to_plot = ( [@dayofweek], [@canning], [@multipack], [@quest] ); which I can happily feed into GD::Graph to get a pretty graph drawn for me.
I could achieve what I need to by doing three separate queries of the database and pushing results into a separate array each time. Or a lot of if, elsif, else pattern matching. Indeed the former is what I'm currently doing. However I'm sure there is a 'better' way.
A way, but I am led to understand a bad way, of achieving this would be to try and push the Output figure, $results2, for each line of results into an array which has as it's name the value of the Production Line, $results1. I think this is possible, though I haven't managed to work out the syntax (despite a good look through Chapter 9, Data Structures, of Programming Perl). However in searching online for an example of the syntax I came across a copy of a newsgroup post about why naming variables with other variables is a bad idea.
Thus I have journeyed to prostrate myself before the gates of the Monastery to ask for any drops of wisdom that a passing monk might care to pass my way.
2mths - Thoroughly depressed at his lack of understanding and seeming inability to rectify the situation.