Gossamer Forum
Home : General : Perl Programming :

Using CGI.pm to sub & for ;

Quote Reply
Using CGI.pm to sub & for ;
I wonder if anyone could help me...

I'm currently using CGI.pm to handle all common sub-routines and common tasks which I do not wish to repliace myself.

However, I want to be able to pass variables onto the script, deliminated by a ; (or any other character for that matter) instead of the usual & character.

I was wondering if there is a simple ammendmant I could do to the code I already have to change this?

I'm currently using:

use CGI;

$query = new CGI;

$query->import_names('A');

to import all variables into the A:: name space. I guess I could go in and edit the actual module quite easily, but this program will be hosted on a shared server and I doubt they will let me do any changes that might affect a hundred other users <g>.

Thanks for any idea syou may have.

- wil
Quote Reply
Re: [Wil] Using CGI.pm to sub & for ; In reply to
I don't think there's another way.

Why do you want to do it anyway? .....just to be like GT? Tongue

Well if you can't edit the hosts module you could always upload your own copy ;)

Last edited by:

RedRum: Oct 15, 2001, 3:46 AM
Quote Reply
Re: [RedRum] Using CGI.pm to sub & for ; In reply to
Because in [url=http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=162659;sb=post_latest_reply;so=DESC;forum_view=forum_view_collapsed;]this thread[/url], Michael stated one advantage of using ; over & is to increase the chance of your pages being indexed by the big search engines.

If this is true, then I would most definitily be interested in doing this. A lot of my pages are churned up by perl, and if I can find a way of increasing their chances of being indexed, great.

- wil
Quote Reply
Re: [Wil] Using CGI.pm to sub & for ; In reply to
I'd be interested to know why.
Quote Reply
Re: [Wil] Using CGI.pm to sub & for ; In reply to
Just to come back to this topic, after emailing Lincoln Stein (the author of CGI.pm) it seems that this has been implemented right from the beginnning. It's an unknown 'feature'.

You can deliminate your vars passed to a form using & or ; and it will pick both up. Great news!

And as for the reason why, here's a quote from HTML 2 spec:

Quote:
(26)

The URI from a query form submission can be used in a normal anchor style hyperlink. Unfortunately, the use of the `&' character to separate form fields interacts with its use in SGML attribute values as an entity reference delimiter. For example, the URI `http://host/?x=1&y=2' must be written `<a href="http://host/?x=1&#38;y=2"' or `<a href="http://host/?x=1&amp;y=2">'. HTTP server implementors, and in particular, CGI implementors are encouraged to support the use of `;' in place of `&' to save users the trouble of escaping `&' characters this way.

Cheers

- wil