XS(3)
β¨ NAME β¨
okay so bestie, welcome to CGI::Deurl::XS β it's a fast decoder for URL parameter strings π (yes that's the whole name, and yes it's iconic). It lives in the user-contributed Perl documentation, section 3, so when you see XS(3) around town, that's this girl.
π¦ SYNOPSIS π¦
here's the whole vibe in four lines, no cap:
use CGI::Deurl::XS 'parse_query_string';
my $hash = parse_query_string('foo=bar&baz=quux&baz=qiix');
# $hash = { 'foo' => 'bar', 'baz' => ['quux', 'qiix'] };
look at that second one β baz showed up twice and got itself an array. main character behavior fr fr π
πΈ DESCRIPTION πΈ
so this module decodes a URL-encoded parameter string in the manner of CGI.pm. that's the whole point. but the way it does it?? it uses C code from libapreq to do the job, which means it's somewhere from slightly to much faster (depends on your strings, it's giving β¨it dependsβ¨) than using CGI or a functionally similar module like CGI::Deurl.
basically: same output, way less yapping. slay π
π FUNCTIONS π
π parse_query_string()
$hash_ref = CGI::Deurl::XS::parse_query_string($query_string)
okay so this one parses the given query string, here's the tea:
- if the string is empty, it returns
undef. that's it, that's the whole answer, go home π«Ά - otherwise it returns a hash reference containing the key/value pairs encoded by the string.
- empty values are returned as
undefβ not'', not nothing, literallyundef, noted π - if a parameter appears only once, its value in the hash is the scalar value of the encoded parameter value.
- if a parameter appears more than once, the hash value is an array reference containing each value given, with value order preserved. queen behavior.
- but obviously, parameter order is not preserved in the hash β hashes don't do that, bestie, that's just not their thing π
and the encoding part, which is lowkey the most important bit:
- HTTP escapes (ASCII and Unicode) are decoded in both keys and values β¨
- the
utf8flag is not set on returned strings π« - and non-utf8 encodings are not decoded either π«
so like. it decodes the escapes. it does not do the whole character-encoding journey for you. know the difference, iykyk π§
π EXPORT π
- None by default β nothing jumps into your namespace uninvited, we're polite here π
parse_query_stringβ but only at request, so you gotta ask for it nicely (that's theuse CGI::Deurl::XS 'parse_query_string';up there β¬οΈ)
π SEE ALSO π
CGIlibapreq
(the first one is the vibe it's matching, the second one is the C muscle behind the curtain π¦)
π AUTHOR π
Adam Thomason, <athomason@sixapart.com> β thank you for your service, legend π«‘π
π COPYRIGHT AND LICENSE π
Copyright (C) 2008 by Six Apart Ltd <cpan@sixapart.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
tl;dr: it's free software, same terms as Perl itself, pick your Perl version, live your truth β¨
and that's the whole page bestie!! this manual shipped as XS(3) from perl v5.42.0, dated 2025-07-25, under User Contributed Perl Documentation. go forth and parse those query strings, you absolute icon πΈπ
π
π¦ where this page comes from
- fedora 43: perl-CGI-Deurl-XS 0.08-34.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms