XS(3)

πŸ“¦
version 0.08 Β· 2 versions
, in fedora 43

✨ 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, literally undef, 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 utf8 flag 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 the use CGI::Deurl::XS 'parse_query_string'; up there ⬆️)

🌈 SEE ALSO 🌈

  • CGI
  • libapreq

(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 (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