Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Read JSON data from a form (CGI->Vars)

by Anonymous Monk
on Dec 30, 2013 at 01:13 UTC ( [id://1068706]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Read JSON data from a form
in thread Read JSON data from a form

FWIW, you don't need to know the name, param without args provides the names , Vars mangles (encodes, serializes, packs, implodes) the data, its backwards compatibility for some 1993 stuff
#!/usr/bin/perl -- use Data::Dump qw/ dd /; use CGI; my $q = CGI->new(q{a=b;a=c;d=e;f=g}); my %Vars = map { $_ => [ $q->param($_) ] } $q->param(); dd( $q ); dd( $q->Vars ); dd( \%Vars ); __END__ __END__ bless({ ".charset" => "ISO-8859-1", ".fieldnames" => {}, ".parameters" => ["a", "d", "f"], "escape" => 1, "param" => { a => ["b", "c"], d => ["e"], f => ["g"] }, "use_tempfile" => 1, }, "CGI") ("a", "b\0c", "d" .. "g") { a => ["b", "c"], d => ["e"], f => ["g"] } bless({ ".charset" => "ISO-8859-1", ".fieldnames" => {}, ".parameters" => ["a", "d", "f"], "escape" => 1, "param" => { a => ["b", "c"], d => ["e"], f => ["g"] }, "use_tempfile" => 1, }, "CGI")
#!/usr/bin/perl -- use Data::Dump qw/ dd /; use CGI; my $q = CGI->new(q{a=b;a=c%00d;d=e;f=g}); my %Vars = map { $_ => [ $q->param($_) ] } $q->param(); dd( $q ); dd( $q->Vars ); dd( \%Vars ); __END__ bless({ ".charset" => "ISO-8859-1", ".fieldnames" => {}, ".parameters" => ["a", "d", "f"], "escape" => 1, "param" => { a => ["b", "c\0d"], d => ["e"], f => ["g"] }, "use_tempfile" => 1, }, "CGI") ("a", "b\0c\0d", "d" .. "g") { a => ["b", "c\0d"], d => ["e"], f => ["g"] }

Replies are listed 'Best First'.
Re^5: Read JSON data from a form (CGI->Vars)
by Anonymous Monk on Jan 07, 2015 at 09:05 UTC

    Naming things is hard :/

    #~ sub CGI::fornew { #~ sub CGI::HashVars { #~ sub CGI::VARTS { #~ sub CGI::old { #~ sub CGI::wen { #~ sub CGI::Varses { sub CGI::Wars { my $q = shift; my %Vars = map { $_ => [ $q->param($_) ] } $q->param(); return \%Vars; }
Re^5: Read JSON data from a form (CGI->VarsAsHash )
by Anonymous Monk on Jan 07, 2015 at 08:55 UTC
    sub CGI::AsHash { my $q = shift; my %hash; $hash{$_} = $q->param($_) for $q->param; return \%hash; }
    my $params = CGI->new->AsHash;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1068706]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found