in reply to Using Variables with Variables

As Joost mentioned, an array would fix your immediate problem. However, it's much simpler to fix. Most folks don't seem to know this, but the following is a legal query string (semicolons are the preferred delimiter, but people don't seem to know that, either):

sport=football;sport=basketball;sport=sheep%20tossing

Yes, that has three 'sport' parameters. Then you can slurp all of them into an array at once:

my @sports = param('sport');

The param function in CGI.pm returns the first value in scalar context and all values in list context. Then, rather than having to have differently named fields in your form and having to remember to keep your code in synch with the field names, you give all identical types in the form the same name and have your code iterate over them without worrying about the indexes.

Cheers,
Ovid

New address of my CGI Course.