|
CGI::UriThingy - a fewest set of functions about uri thingies. |
CGI::UriThingy - a fewest set of functions about uri thingies.
use CGI::UriThingy qw(urlencode urldecode);
my %input = (
'name' => 'Masanori HATA',
'mail' => 'lovewing@dream.big.or.jp',
'home' => 'http://go.to/hata',
);
my $encoded = urlencode(%input);
print $encoded;
my %output = urldecode($encoded);
print 'name: ', $output{'name'}; # displays "name: Masanori HATA"
This module provides four minimal functions about urlencode and uri-escape those which could be needed for CGI program.
urlencode(%param)%param (the names and the values pairs), this function escape, combine and return urlencoded string. A urlencoded string has jointed the names and the value pairs by ``&'' character, and a name/value pair has jointed the name and the value by ``='' character.
Though it is expressed virtually input with a hash (%), it is actually input with an arry (@). So, jointed name/value pairs appear in urlencoded string be in exact sequence of which they have been given. That you can control sequence of name/value pairs appear in urlencoded string. If you just give a real hash (%) to this function, order of name/value pairs appear in urlencoded string should be random.
$encoded = urlencode(
name1 => value1,
name2 => value2,
(...)
);
$encoded = "name1=value1&name2=value2&(...)";
Note that the application/x-www-form-urlencoded is specified in HTML 4 http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1.
urldecode($string)%param = urldecode($encoded);
uri_escape($string)uri_unescape($string)
Masanori HATA http://go.to/hata (Saitama, JAPAN)
Copyright (c) 1999-2005 Masanori HATA. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
CGI::UriThingy - a fewest set of functions about uri thingies. |