URI::Query::FromHash - Construct a query string from a hash ref
use utf8;
use URI::Query::FromHash;
my $query_string = hash2query {
foo => 'bar',
baz => [ qw/qux quux/ ],
utf8 => '☃',
};
# or
my %args = ...;
my $query_string = hash2query %args;
URI::Query::FromHash aims to be a fast, light query string constructor.
Inspired by Ruby on Rails' to_query hash method.
Accepts a hash ref of query parameters. The value of each parameter must either by a simple scalar or an array ref of simple scalars.
All strings are assumed to be UTF-8 decoded values.
$ perl -Ilib example/bench.pl
Rate uri hash2query
uri 24436/s -- -59%
hash2query 59077/s 142% --
Copyright © 2016 by James Raspass
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.