CGI::Struct::XS(3pm)
π CGI::Struct::XS π
okay bestie so this is CGI::Struct::XS, a Perl module living in the User Contributed Perl Documentation section of the manual. It's the glow-up version of CGI::Struct, and it's fast.
β¨ DESCRIPTION β¨
So basically, this module is the XS implementation of CGI::Struct. It is fully compatible with CGI::Struct β like, every single thing works the same β with exactly one exception: the error messages. Those are different. That's it.
And the speed? Not me being dramatic, but CGI::Struct::XS is 3-15 times faster than the original module β and 5-25 times faster when dclone is disabled. She ate. π
πΈ SYNOPSIS πΈ
First vibe, with good old CGI:
use CGI;
use CGI::Struct::XS;
my $cgi = CGI->new;
my %params = $cgi->Vars;
my $struct = build_cgi_struct \%params;
...
Or, if you're a Plack girlie:
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 };
...
};
π¦ FUNCTIONS π¦
build_cgi_struct
$struct = build_cgi_struct \%params;
$struct = build_cgi_struct \%params, \@errs;
$struct = build_cgi_struct \%params, \@errs, \%conf;
The only function this module exports is build_cgi_struct, and she takes three arguments. Let's go through them one by one, no gatekeeping:
\%paramsβ a HashRef stuffed with your input values. Usually this is aCGIparams hashref or a Plack params hashref. Standard.\@errsβ an ArrayRef where error messages get stashed. If it's not defined, then every parsing error just gets silently discarded. Gone. Nothing to see here. π\%confβ a HashRef with your parsing options. Details below, bestie.
the options, in list form β¨
nodotβ treat the dot as an ordinary character, not as a hash delimiter.nullsplitβ split input values on the"\\0"character. This one's for you if you're dealing with old CGI libraries.dcloneβ store a deep clone of the value instead of the original value. Heads up though: this option increases memory consumption and slows parsing down. The recommendation is to disabledclone, because in most cases CGI params get used as read-only variables anyway, so like... why clone? Not needed, babe.
π SEE ALSO π
CGI::Struct
k that's the whole page, you're all caught up π
This page came to you from perl v5.42.3, dated 2026-08-20, and it's the CGI::Struct::XS(3pm) page under User Contributed Perl Documentation. slay, go build some structs β¨π
π¦ where this page comes from
- ubuntu stonking: libcgi-struct-xs-perl 1.04-3build5 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms