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

Thanks - My site is definately down so I won't get to test this until the dorks who host me get their act together. This doesn't really answer my question, but it looks like a viable alternative. I bounced my questions off my MIT pal, stumped him something else. Surely something so simple can be done with just a line of code! At any rate, gracias
  • Comment on Re: Answer: How can I specify which array to use with $ENV(queary_string)?

Replies are listed 'Best First'.
Re: Re: Answer: How can I specify which array to use with $ENV(queary_string)?
by jaldhar (Vicar) on Dec 10, 2001 at 20:13 UTC

    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.