use Modern::Perl; use URI::Escape qw/uri_escape/; my @t = qw(name John number 7 status unknown); my %th = @t; # cast to hash my $str = join '&', map { sprintf '%s=%s', uri_escape($_), uri_escape($th{$_}) } keys %th; say $str;