List Info

Thread: Re: Skip get arguments on the URL




Re: Skip get arguments on the URL
country flaguser name
United States
2007-08-15 11:30:48

Hi Randal,

Once again always to the rescue. I am afraid I did
not make myself clear on the previous email. My cgi
script sets default values as '' and then the database
query skips those parameters. My problem is that I
want to invoke my cgi script from the URL without any
of the parameters except the one I am searching with.
Is this possible? So let's say that the form has two
cgi params, param1 and param2. So the GET URL would
be
search.cgi?param1=&param2=something if I wanted to
search only by param2. If I type
search.cgi?param2=something the cgi script does not
work. But that would be very convenient cause my
friend needs to set all params to nothing which makes
his html code very cumbersome. Is there a way to chop
the GET URL?

Thanx
Dinos

--- "Randal L. Schwartz&quot; < merlyn%40stonehenge.com">merlynstonehenge.com>
wrote:

> >>&gt;>> "Dinos" == Dinos Liolios < dinos007%40yahoo.com">dinos007yahoo.com>
>; writes:
>
> Dinos> Hello. I have written a search cgi script
&gt; which has a
> Dinos> lot of arguments with which you can search a
> database.
> Dinos> Now a friend of mine wants to create a tree
>; using
&gt; 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&amp ;gen_type=ALL&org_name1=genus&gensp=&org_domain=ARCHAEAL&;org_status=ALL&size2=ALL&amp;org_size=Kb&gen_gc=ALL&amp;gen_seqmethod=ALL&gen_temperature=ALL&gen_ph=ALL&amp;gen_symbiont=ALL&amp;phylogeny2=ALL&;gen_institution=ALL&amp;gen_funding=ALL&amp;gen_data=ALL&cont=ALL&amp;gen_country=ALL&amp;gen_pheno=ALL&gen_habitat=ALL&gen_disease=ALL&gen_relevance=ALL&gen_avail=ALL&selection=submit+search
>
> Dinos> I would like to have:
&gt; Dinos>
>
http://genomesonline.org/search.cgi?org_domain=ARCHAEAL&selection=submit+search
&gt;
> Here's my code:
&gt;
> 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&amp ;gen_type=ALL&org_name1=genus&gensp=&org_domain=ARCHAEAL&;org_status=ALL&size2=ALL&amp;org_size=Kb&gen_gc=ALL&amp;gen_seqmethod=ALL&gen_temperature=ALL&gen_ph=ALL&amp;gen_symbiont=ALL&amp;phylogeny2=ALL&;gen_institution=ALL&amp;gen_funding=ALL&amp;gen_data=ALL&cont=ALL&amp;gen_country=ALL&amp;gen_pheno=ALL&gen_habitat=ALL&gen_disease=ALL&gen_relevance=ALL&gen_avail=ALL&selection=submit+search
> INLINE_TEXT
> my query_form = $uri->query_form; # get the
> current params
&gt; 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:
&gt; next unless defined $value and length $value;
> # skip empty values
&gt; 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
&gt; "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';
&gt;
> would eliminate that item.
&gt;
> --
> Randal L. Schwartz - Stonehenge Consulting Services,
> Inc. - +1 503 777 0095
>; < merlyn%40stonehenge.com">merlynstonehenge.com>
> <URL:http://www.stonehenge.com/merlyn/>
&gt; Perl/Unix/security consulting, Technical writing,
> Comedy, etc. etc.
>; See PerlTraining.Stonehenge.com for onsite and
> open-enrollment Perl training!
>

www.i-dinos.com

__._,_.___
.

__,_._,___
Re: Skip get arguments on the URL
country flaguser name
United States
2007-08-15 12:21:26

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

Dinos>; Once again always to the rescue. I am afraid I did
Dinos> not make myself clear on the previous email. My cgi
Dinos> script sets default values as '' and then the database
Dinos> query skips those parameters. My problem is that I
Dinos&gt; want to invoke my cgi script from the URL without any
Dinos> of the parameters except the one I am searching with.
Dinos&gt; Is this possible? So let's say that the form has two
Dinos> cgi params, param1 and param2. So the GET URL would
Dinos> be
Dinos&gt; search.cgi?param1=&amp;param2=something if I wanted to
Dinos> search only by param2. If I type
Dinos> search.cgi?param2=something the cgi script does not
Dinos> work. But that would be very convenient cause my
Dinos> friend needs to set all params to nothing which makes
Dinos> his html code very cumbersome. Is there a way to chop
Dinos> the GET URL?

That is exactly what my code does. I used your example which had a lot of
non-empty things. If you had given a different example URL, it would have
worked more like you wanted.

--
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.

Yoga Resources

on Yahoo! Groups

Take the stress

out of your life.

[1-2]

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