says that the meta-variables (which include the QUERY_STRING) are passed to the script in identically named environment variables. These are accessed by the C library
routine getenv() or variable environ. (item 7.2 of RFC3875).
As thus the environment variables are populated outside of your script by the server, you will have to find a way to capture these variables in a local data structure before messing around with them.
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James