in reply to accessing random count CGI parameters

You don't need the "xxxc=2" part of the query string as the CGI-module will know all by itself the number of parameters input, unless you use that value as some sort of (weak) checksum.

Anyhow it is far better to rely on CGI.pm (or its brethren such as CGI:Simple) to do the parsing.

And in order to sequentially access the parameters just sort the key-values of the parameter-hash and use that sorted list to go through the values of the parameters.

CountZero

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

Replies are listed 'Best First'.
Re^2: accessing random count CGI parameters
by shmem (Chancellor) on Jun 25, 2007 at 11:19 UTC
    And in order to sequentially access the parameters just sort the key-values of the parameter-hash and use that sorted list to go through the values of the parameters.

    ... just to extend that - "sort numerically", as in

    perl -le 'print for sort {$a <=> $b} qw(bbb1 aaa2 ccc3 xxx15 def159)' bbb1 aaa2 ccc3 xxx15 def159

    So the snippet would be

    foreach my $key ( sort {$a <=> $b} $q->param() ) { my $value = $q->param($key); # now do whatever with $value ... }

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}