Pyro3k has asked for the wisdom of the Perl Monks concerning the following question:

Well, i dont know what its called, but all Perl forums, even PHP forums use it, this site does also, i asked on the IkonBoard coding help forum about it, no one could help, well, i wanted to know how to use the came type of thing u guys have here, ?node=somethinghere, and have it send me to a page or show some specific text, but all attempts to find help had failed. I asked alot of people, all the people i have on my ICQ list that know CGI, and the people in the ikonboard forums, can someone help me with this, give me the code i need or a example script. Well, thats my question, im still a newbie in case your wondering.

Edit kudra, 2001-07-13 Changed title

Replies are listed 'Best First'.
Re (tilly) 1: i dont know exactly what its called
by tilly (Archbishop) on Jul 13, 2001 at 05:00 UTC
    Following up on what myocom said, everything following the ? in a web URL is called a query string. It takes the form:
    name_1=value_1&name_2=value_2&name_3=value_3
    where both have been encoded in a particular way. For instance if your variable names were city, date and max_temp you might see:
    city=New+York&date=20010912&max_temp=79
    A complete CGI script that uses this might be:
    #! /usr/bin/perl -w use strict; use CGI qw(:standard); my $city = param('city'); my $date = param('date'); my $max_temp = param('max_temp'); print header( -type=>'text/plain' ), "The hottest it got in $city on $date was $max_temp F.";
Re: i dont know exactly what its called
by myocom (Deacon) on Jul 13, 2001 at 04:21 UTC

    Everything after the ? in a URL is the query string that's passed through the GET method of a form. You should read up on HTML forms. I suspect you'd get a lot out of http://www.w3schools.com.

Re: i dont know exactly what its called
by Zaxo (Archbishop) on Jul 13, 2001 at 05:17 UTC

    As myocom pointed out, '?node=somethinghere' is a CGI query using method GET. It doesn't necessarily come from an HTML form, anchors and links can be written with such queries in their href.

    The CGI script's basic job is to examine the query parameters, decide what to do, and print the correct HTML response page. Each of those stages can depend on the name/value pairs passed to the script.

    A few tips:

    1. use warnings;
    2. use strict;
    3. use CGI;
    4. Taint mode should be on.
    5. Know what you expect to see in parameters, and ignore anything unexpected.

    1, 2, and 4 are there to drive you nuts, but it's worth it. They go a long way toward assuring stable and correct behavior. 3 is a convenience which is superior to home-rolled ways of accessing CGI parameters. 5 works with taint mode to prevent clients from persuading your script to do unexpected things.

    Good luck, have fun.

    After Compline,
    Zaxo

Hmm....
by LD2 (Curate) on Jul 13, 2001 at 04:25 UTC
    This site is run on the Everything Engine which run by The Everything Development Company(which is stated on the bottom of every page here) - check out the site. It has documentation as well as the source.

    If you're talking about the URL query string and CGI - I'm not sure... but here is some information from the CGI documentation:
    MIXING POST AND URL PARAMETERS $color = $query->url_param('color'); It is possible for a script to receive CGI parameters in the URL as we +ll as in the fill-out form by creating a form that POSTs to a URL con +taining a query string (a "?" mark followed by arguments). The param( +) method will always return the contents of the POSTed fill-out form, + ignoring the URL's query string. To retrieve URL parameters, call th +e url_param() method. Use it in the same way as param(). The main dif +ference is that it allows you to read the parameters, but not set the +m. Under no circumstances will the contents of the URL query string inter +fere with similarly-named CGI parameters in POSTed forms. If you try +to mix a URL query string with a form submitted with the GET method, +the results will not be what you expect.


    Oops.. I think I possibly misread the question. My apologies. Please delete if so.
Re: What is a Query String in a URL
by aardvark (Pilgrim) on Jul 13, 2001 at 17:55 UTC
    The semantics and structure of a Query String is defined in RFC 2396
    Section 3.4 talks about the Query Component of a URI.

    If you want to get a rock solid understanding of query strings read the specifications. Then you will have an easier time understanding how different applications use them.

    W3C section on Naming and Addressing: URIs, URLs, ...

    Get Strong Together!!