This is a little module made for CGI scripting. It encodes the parameters to be passed to a CGI. It does nothing more, so it's much smaller and loads more quickly.
Encodes the parameter. If the parameter is a single string it encodes it and returns the encoded form.
If it is an array or a reference to an array it encodes all items and returns them joined by '&'.
If it is a hash it encodes the values and return a querystring in form ``key2=encoded_value1&key2=encoded_value2&...''.
!!! Please note that a hash in a list context returns a list of all keys and values. This means that if you call enurl(%hash) you will NOT get what you may thing you should. You HAVE to use enurl(\%hash) !!!
Encodes the parameter, this version doesn't encode '=' and '&' characters, so you should make sure they are not present in the data.
You may specify another character to be used as the parameter separator. Simply set this variable to the character (or string) you want to use.
This variable contains the characters that should stay unencoded. Please keep in mind that the string will be interpolated into a regexp in a [^...] group!
Any change of this variable will be ignored after the first call to enurl or enURL. (I'm using /o switch in the regexp.) So if you want to change the variable you should do it as soon as posible. You may do that even before you ``use'' the module!
# use other name instead of enurl if you like.
# the "var" is necessary !
# without it you will get : "Odd number of elements in hash list at ... line 2."
Please read the docs for enurl versus enURL so that you understand the difference!
The enurl_str function is taken from CGI.pm. (It's named 'escape' there.) Thanks.
Copyright (c) 1997 Jan Krynicky <Jenda@Krynicky.cz> All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.