Dear Fellow Monks,

I have this bunch of Perl-scripts which together make a nice dynamic website.

Now, for various reasons I must place in a web-page an href-link to another script. This other script expects to receive a number of parameters through the GET-protocol, which I therefore encode into the URL put into the href.

Say that the href turns out to be href='script.pl?company=IBM&place=Brussels'. This works nice and fine: script.pl happily obtains both parameters (thanks to CGI.pm of course) and outputs another dynamic webpage.

Now it comes to pass that the name of the company is "Smith & Jones" and the href becomes href='script.pl?company=Smith & Jones&place=Brussels'.

All of a sudden, script.pl sees only "Smith " in the company -parameter and a third parameter "Jones" pops into being.

Obviously the "&" between "Smith" and "Jones" was seen to be a delimiter, rather than part of the company-parameter.

Vainly I tried to find a way to escape this "&": All to no avail, CGI.pm seems to unescape all "&"-entities prior to parsing the URL for the GET-parameters.

I looked through the CGI-docs but could not find a solution.

Does anyone has a suggestion how to sneak in an "&" into a GET-parameter?

Although I do not think it has anything to do with this problem, I mention that my scripts do not directly output HTML, but XML which get server-side transformed into HTML by XSLT.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


In reply to CGI : How to put an "&" into a GET-parameter by CountZero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.