CGI::Struct::XS - Build structures from CGI data. Fast.
This module is XS implementation of CGI::Struct. It's fully compatible with CGI::Struct, except for error messages. CGI::Struct::XS is 3-15 (5-25 with dclone disabled) times faster than original module.
CGI::Struct::XS
use CGI; use CGI::Struct::XS; my $cgi = CGI->new; my %params = $cgi->Vars; my $struct = build_cgi_struct \%params; ...
Or
use Plack::Request; use CGI::Struct::XS; my $app_or_middleware = sub { my $env = shift; # PSGI env my $req = Plack::Request->new($env); my $errs = []; my $struct = build_cgi_struct $req->parameters, $errs, { dclone => 0 }; ... }
$struct = build_cgi_struct \%params; $struct = build_cgi_struct \%params, \@errs; $struct = build_cgi_struct \%params, \@errs, \%conf;
The only exported function is build_cgi_struct. It has three arguments:
build_cgi_struct
\%params
HashRef with input values. Typicaly this is CGI or Plack params hashref
\@errs
ArrayRef to store error messages. If it's not defined all parsing errors will be sielently discarded.
\%conf
HashRef with parsing optiosn
Following options are supported:
nodot
Treat dot as ordinary character, not hash delimeter
nullsplit
Split input values by \\0 characeter, usefull for old CGI libraries
\\0
dclone
Store deep clone of value, instead of original value. This opion increase memory consumsion and slows parsing. It's recomended to disable dclone, because in most cases CGI params are used as read-only variables.
CGI::Struct
To install CGI::Struct::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Struct::XS
CPAN shell
perl -MCPAN -e shell install CGI::Struct::XS
For more information on module installation, please visit the detailed CPAN module installation guide.