CGI-Deurl
view release on metacpan or search on metacpan
character or string you want. This must be the first option if present!
The parameter separator is stored in variable $CGI::Deurl::ParamSeparator.
You may change it any time you want.
=item use CGI::Deurl 'JOIN' => ';';
=item use CGI::Deurl 'JOIN' , 'file' => ';', '-all' => ',';
This option will cause a call to joinquery(), all folowing arguments
will be passed to this function, so this switch has to be the last one!
=back
=head2 Parsing query
If the argument in the query in in the form "name=value".
$CGI::Deurl::query{name} is set to value. If it is just "value"
(say myscript.pl?one&two), $CGI::Deurl::query{0}='one' and
$CGI::Deurl::query{1}='two'. These kinds of parameters can be intermixed.
If there is more than one occurence of a variable,
$CGI::Deurl::query{name} contains a refference to an array containing
all the values.
Ex.
?x=one&y=two&x=three
=>
$CGI::Deurl::query{x}=['one','three'];
$CGI::Deurl::query{y}='two';
!!! If you 'export' such a variable it's not exported as a refference
but as a real array!!!
That is if you use CGI::Deurl qw(export CGI::Deurl) you will get :
@CGI::Deurl::x = ('one','three');
$CGI::Deurl::y = 'two';
! All changes made to $CGI::Deurl::variable are visible in
$CGI::Deurl::query{variable} and vice versa.
=head2 Functions
=over 4
=item deurl
=item deurl $string, \%hash
Decodes the string as if it was an ordinary CGI query.
The %hash then contains all CGI parameters specified there.
Ex.
deurl('a=5&b=13',\%query);
leads to :
$query{a} = 5;
$query{b} = 13;
=item deurlstr
=item $decodedstring = deurlstr $string
Decodes the string as if it was a CGI parameter value.
That is ist translates all '+' to ' ' and all
%xx to the corresponding character. It doesn't care about
'&' nor '='.
Ex.
$result = deurlstr 'How+are+you%3F';
leads to:
$result = 'How are you?'
!!! but notice that !!!
$result = deurlstr('a=5&b=13%25');
gives:
$result = 'a=5&b=13%'
!!!!!!
=item deurlarr
=item @result = deurlarr $string;
Decodes the string as a sequence of unnamed CGI parameters,
that is it supposes that the $string looks somehow like this :
'param1¶m2&par%61m3'. It doesn't care about '='
Ex.
@result = deurlarr 'How&are+you%3f';
leads to
@result = ( 'How', 'are you?');
@result = deurlstr('a=5&b=13%25');
gives:
@result = ( 'a=5', 'b=13%');
which may but may not be what you want.
=item CGI::Deurl::load
Instructs CGI::Deurl to load the CGI data from QUERY_STRING, @ARGV or <STDIN>.
The parameters are the same as for the C<use CGI::Deurl ...;>
Usefull only if you C<use CGI::Deurl NOTCGI;>, but later on you find out you want
the CGI parameters.
=item joinquery %query, $delimiter
=item joinquery %query, $key => $delimiter [, ...]
If the query contains several values for a singe variable, these values
are stored as an array in the hash. This function joins them using the delimiter
you specify. You may either join all the keys using the same delimiter, or use different
delimiters for each key. You may even leave some values intact.
Ex.:
joinquery %query, $delimiter
it will join all multivalues it finds using the $delimiter.
joinquery %query, 'key' => $delimiter
it will join only the multivalue for 'key'. All other values will remain
the same.
joinquery %query, 'key' => ';', '-all' => ' '
it will join the multivalue for 'key' by semicolons. All other values will
( run in 0.805 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )