If you want to include an ampersand in a query string argument, the easiest way is to hex-encode it, the same way spaces are done. Spaces (decimal 32, hex 20) are encoded as %20 in URIs, which I'm sure you've seen at some point (here on Perlmonks if nowhere else). I think ampersand would be %26 if I've done the conversion correctly. Of course, whatever you use to get the query args has to know how to unencode this; if you are using a well-known module, that should not be a problem.
HTH.HAND
update:
I neglected to mention that the browser should do this
conversion automatically, if you put the thing in the
value attribute of a hidden field (or, for that matter,
any form field at all (update2: though yes,
you'd need to encode the entities in that case
(presumably with HTML::Entities))).
However, if you're
putting it in an href, then you have to (hex) encode it
first. Some of the CGI-related modules may
provide functions for doing this (update3:
such as URI::Escape), but it's also pretty
trivial to do by hand, along the lines of this
(which, however, I have not extensively tested):
$foo =~ s/(\W)/"%".sprintf "%02x",ord$1/eg;
"In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."
— Pratico & Van Pelt, BBHG, p68
| [reply] [d/l] |
There's no need to reinvent this wheel. URI::Escape is part of the Perl "core"
perl -MURI::Escape -le 'print uri_escape "search&l=phone&s=$query&r=10
+0&m=&p=\$cnt"'
__OUTPUT__
search%26l%3Dphone%26s%3D%26r%3D100%26m%3D%26p%3D%24cnt
Watch out for that $cnt though. I escaped it with \ to keep it from being interpolated, which may or may not be what the OP needs. | [reply] [d/l] [select] |
URI::Escape is not part of the Perl core
| [reply] |
<input type='hidden' value='search&l=phone&s=$query&r=100&
+amp;m=&p=$cnt'>
<a href='$url?search%26l%3dphone%26s%3d%24query%26r%3d100%26m%3d%26p%3
+d%24cnt'>
And once you realize that, it makes perfect sense why there's the push to use ; as its seperator (which you don't need to HTML escape) | [reply] [d/l] [select] |
| [reply] |