himanshu.padmanabhi has asked for the wisdom of the Perl Monks concerning the following question:

If I get two values of any variable in my form,then how do I access both or how do I know there are two values?
Dumper(idx=8&args=&myname=ABCD.txt&idx=+&myname=+)
like here,'idx' and 'myname' contains 2 values. I am using ReadParse method of webmin module.It contains %in hash though which I can access elements from previous form. so in this form,to get 'myname',I can use $in{'myname'}

Replies are listed 'Best First'.
Re: Two values for same variables in %in hash
by shmem (Chancellor) on Mar 04, 2009 at 09:58 UTC

    I guess that the ReadParse is from CGI. If that is the case, multiple values under a key are concatenated together using the ASCII 0 character (NUL Byte):

    perl -MCGI -le 'CGI::ReadParse(); print for split /\0/, $in{myname}' \ 'idx=8&args=&myname=ABCD.txt&idx=+&myname=foobar'

    Output:

    ABCD.txt foobar
Re: Two values for same variables in %in hash
by Anonymous Monk on Mar 04, 2009 at 12:26 UTC
    Don't use ReadParse for new programs, use param