in reply to I really need help with perl data structures and HTML::Template
Results:use Data::Dumper; my %hash = ('a'=>1, 'b'=>2, 'b'=>3); my @array = ('c','d','e','f'); my $data = {%hash}; $data->{'array'} = [@array]; $data->{'array'}[4] = {%hash}; $data->{'array'}[4]{'foobar'} = [@array]; print Data::Dumper->Dump([$data], ['data']);
And you can use it to print out any unknown object, such as a CGI object:$data = { 'a' => 1, 'b' => 3, 'array' => [ 'c', 'd', 'e', 'f', { 'foobar' => [ 'c', 'd', 'e', 'f' ], 'a' => 1, 'b' => 3 } ] };
I entered in values of 'foobar=val, and 'submit=sumbit' and the Results:use CGI qw(:standard -debug); my $cgi = new CGI; print Data::Dumper->Dump([$cgi], ['cgi']);
The notations for {} mean hash references and the notation for [] is for array references.$cgi = bless( { '.charset' => 'ISO-8859-1', 'foobar' => [ 'val' ], '.parameters' => [ 'foobar', 'submit' ], 'submit' => [ 'sumbit' ], '.fieldnames' => {} }, 'CGI' );
|
|---|