I am trying to fill out a general nested structure
from flat and orderless name=value pairs of CGI params.
I want the name to be split on '.' and used as
multilevel hash keys. The values are scalars or arrays:
my $cgi = CGI->new( 'a.b.c=3&a.b.c=4&x.y=4' );
# convert somehow to:
my $args = { a => { b => { c => [3,4] },
x => { y => 4}
};
I realize that adding a=1 to the above list
would cause problems. As long as I the user can't
cause a "not a HASH ref" error I'm not too concerned
at this stage.
I wrote some cruddy code for this but couldn't
think of a nice way to access and assign to the
nested hash. Any suggestions?
Brad
PS. No $;='.'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.