http://qs1969.pair.com?node_id=541926


in reply to simplifying a CGI param request

my $cnt = 0; my %params; for (1 .. 25) { $cnt++; $params{"q$cnt"} = param("q$cnt"); }
Untested but this will either work or give you the right idea.


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re^2: simplifying a CGI param request
by Anonymous Monk on Apr 07, 2006 at 17:13 UTC
    hashes don't keep them in the order I need. How would I sort them to print out q1, q2, q3 etc in order in a foreach loop?
      You'd take his for loop and instead of putting the stuff in a hash you'd just do something with the number right then and there!
      for (1 .. 25) { my $value = param("q$_"); print "Value #$_ = $value\n"; }

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
        This could work or you could drop the "q" from the hash key and then just do a numeric sort on the hash and add it back in at the end.


        "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

        sulfericacid