CGI::Expand is a Perl module that can convert flat hash to nested data using TT2's dot convention.
SYNOPSIS
use CGI::Expand;
use CGI; # or Apache::Request, etc.
$args = expand_cgi( CGI->new('a.0=3&a.2=4&b.c.0=x') );
# $args = { a => [3,undef,4], b => { c => ['x'] }, }
# Or to catch exceptions:
eval {
$args = expand_cgi( CGI->new('a.0=3&a.2=4&b.c.0=x') );
} or log_and_exit( $@ );
#-----
use CGI::Expand qw(expand_hash);
$args = expand_hash({'a.0'=>77}); # $args = { a => [ 77 ] }
Converts a CGI query into structured data using a dotted name convention similar to TT2.
expand_cgi works with CGI.pm, Apache::Request or anything with an appropriate "param" method. Or you can use expand_hash directly.
If you prefer to use a different flattening convention then CGI::Expand can be subclassed.
Product's homepage
Requirements:
· Perl