CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Use of variable name as variable, even though "dirty"



Sep 26, 2016, 3:47 AM

Post #1 of 2 (2895 views)
Use of variable name as variable, even though "dirty" Can't Post


I've got a set of files and folders containing information on cars. These are put into several different arrays, so that for example $arrayname[0] for each array will provide information on the same car.

This will be presented in a HTML table and I've got a settings page allowing users make settings on what columns they find interesting.

Arrays like below:
@one = (BMW, Volvo, Mercedes)
@two = (2011, 2012, 2009)
@three = (White, Silver, Red)

Now, as an example settings are saved as text "one" and "two" in @settings. Someone wants to view all models with corresponding years.

In the psuedo code below It would be nice to be able to loop through both $i and $j, but I can't seem to figure out how:

print ${ $settings[$i] }[$j];

Veteran / Moderator

Sep 26, 2016, 8:20 AM

Post #2 of 2 (2892 views)
Re: [mrhedin] Use of variable name as variable, even though "dirty" [In reply to] Can't Post

You're using the wrong data structure. Use a hash.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives