List Info

Thread: Skip get arguments on the URL




Skip get arguments on the URL
country flaguser name
United States
2007-08-15 09:45:57

Hello. I have written a search cgi script which has a
lot of arguments with which you can search a database.
Now a friend of mine wants to create a tree using
hardcoded search URL from my site. The obvious URL is
setting to all arguments to empty except the one he
wants to search by. However the is an extremely long
string. I was wondering if it is possible to type
only the argument by which you are searching in the
url.
For example instead of:

http://genomesonline.org/search.cgi?orgcol=org&domcol=dom&typecol=type&;sizecol=size&infocol=info&datacol=data&instcol=inst&analycol=analy&contcol=contact&statuscol=status&goldstamp=ALL&amp ;gen_type=ALL&org_name1=genus&gensp=&org_domain=ARCHAEAL&;org_status=ALL&size2=ALL&org_size=Kb&gen_gc=ALL&gen_seqmethod=ALL&gen_temperature=ALL&gen_ph=ALL&gen_symbiont=ALL&phylogeny2=ALL&;gen_institution=ALL&gen_funding=ALL&gen_data=ALL&cont=ALL&gen_country=ALL&gen_pheno=ALL&gen_habitat=ALL&gen_disease=ALL&gen_relevance=ALL&gen_avail=ALL&selection=submit+search

I would like to have:
http://genomesonline.org/search.cgi?org_domain=ARCHAEAL&selection=submit+search

Thanx in advance
Dinos

www.i-dinos.com

__._,_.___
Recent Activity
Visit Your Group
SPONSORED LINKS
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Fitness Edge

on Yahoo! Groups

Learn how to

increase endurance.

Yoga Groups

Exchange insights

with members of

the yoga community.

Re: Skip get arguments on the URL
country flaguser name
United States
2007-08-15 09:57:50

>>&gt;>> "Dinos" == Dinos Liolios < dinos007%40yahoo.com">dinos007yahoo.com> writes:

Dinos>; Hello. I have written a search cgi script which has a
Dinos&gt; lot of arguments with which you can search a database.
Dinos> Now a friend of mine wants to create a tree using
Dinos> hardcoded search URL from my site. The obvious URL is
Dinos> setting to all arguments to empty except the one he
Dinos> wants to search by. However the is an extremely long
Dinos> string. I was wondering if it is possible to type
Dinos> only the argument by which you are searching in the
Dinos> url.
Dinos> For example instead of:

Dinos> http://genomesonline.org/search.cgi?orgcol=org&domcol=dom&typecol=type&;sizecol=size&infocol=info&amp;datacol=data&instcol=inst&analycol=analy&contcol=contact&amp;statuscol=status&amp;goldstamp=ALL&gen_type=ALL&org_name1=genus&amp;gensp=&org_domain=ARCHAEAL&org_status=ALL&size2=ALL&org_size=Kb&gen_gc=ALL&gen_seqmethod=ALL&;gen_temperature=ALL&gen_ph=ALL&gen_symbiont=ALL&phylogeny2=ALL&gen_institution=ALL&gen_funding=ALL&gen_data=ALL&cont=ALL&gen_country=ALL&gen_pheno=ALL&gen_habitat=ALL&gen_disease=ALL&amp;gen_relevance=ALL&gen_avail=ALL&amp;selection=submit&#43;search

Dinos&gt; I would like to have:
Dinos> http://genomesonline.org/search.cgi?org_domain=ARCHAEAL&selection=submit+search

Here's my code:

use URI;
my $uri = URI->new(<<'INLINE_TEXT');
http://genomesonline.org/search.cgi?orgcol=org&domcol=dom&typecol=type&;sizecol=size&infocol=info&amp;datacol=data&instcol=inst&analycol=analy&contcol=contact&amp;statuscol=status&amp;goldstamp=ALL &gen_type=ALL&amp;org_name1=genus&;gensp=&amp;org_domain=ARCHAEAL&org_status=ALL&amp;size2=ALL&org_size=Kb&amp;gen_gc=ALL&gen_seqmethod=ALL&gen_temperature=ALL&amp;gen_ph=ALL&gen_symbiont=ALL&phylogeny2=ALL&gen_institution=ALL&gen_funding=ALL&gen_data=ALL&amp;cont=ALL&gen_country=ALL&gen_pheno=ALL&amp;gen_habitat=ALL&amp;gen_disease=ALL&;gen_relevance=ALL&amp;gen_avail=ALL&selection=submit+search
INLINE_TEXT
my query_form = $uri->query_form; # get the current params
my new_query_form; # now select the elements we want
while (query_form) {
my ($key, $value) = splice query_form, 0, 2;
## select the items you want... not sure what your rule is here:
next unless defined $value and length $value; # skip empty values
next if $value eq 'ALL'; # skip "ALL&quot;
push new_query_form, $key, $value;
}
$uri->query_form(new_query_form); # update the uri
print "$urin"; # and here it is:

The result is:

http://genomesonline.org/search.cgi?orgcol=org&domcol=dom&typecol=type&;sizecol=size&infocol=info&amp;datacol=data&instcol=inst&analycol=analy&contcol=contact&amp;statuscol=status&amp;org_name1=genus&amp;org_domain=ARCHAEAL&org_size=Kb&amp;selection=submit&#43;search

Again... I'm not sure how much of that you want to rip out. Maybe every
&quot;default" value, but I don't know what your default values are. Just
add more steps to that "next" chain above... for example:

next if $key eq 'orgcol' and $value eq 'org';

would eliminate that item.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<; merlyn%40stonehenge.com">merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

__._,_.___
Recent Activity
Visit Your Group
SPONSORED LINKS
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

New business?

Get new customers.

List your web site

in Yahoo! Search.

Yoga Groups

Exchange insights

with members of

the yoga community.

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )