in reply to Re: Answer: How can I specify which array to use with $ENV(queary_string)?
in thread [untitled node, ID 130617]

Whoops! It won't be the first time I misunderstood a question. :-) Though my answer is arguably the 'right' way to do it IMO. You don't want to deal with raw environment variables in a CGI script.

Ok, how about this?

$tdcolor = $ENV{'QUERY_STRING'}[rand scalar @ENV{'QUERY_STRING'}];

The problem is you are feeding rand an array but it really wants a scalar. The scalar function gives you that with the added bonus that if you use it on an array, it return the number of elements in the array. So the net effect is you get a random element from the array. You will notice I used this technique in my earlier answer.

  • Comment on Re: Re: Answer: How can I specify which array to use with $ENV(queary_string)?
  • Download Code