in reply to Re: Stuck
in thread Stuck

Hi Chady. You are having some trouble, and I can't give you a straight, simple, do-one-thing answer (I don't think anybody could). However, if you go back and read all the informative and straightforward replies you got all day from the other monks here, you could probably get a handle on your situation.

Here are my own thoughts on your problem:

  1. Enable warnings by putting a -w after 'perl' on the first line. Like so:
    #!/usr/bin/perl # no warnings #!/usr/bin/perl -w # warnings enabled
    This will give you debugging information that will be output into your Error_Log for Apache, or IIS, or whatever you're using. As it stands, your code is VALID (as far as I can see), it just doesn't do what you want it to. Turning warnings on won't fix this problem directly, but it might help you understand what's going on a little better.

  2. Simplify your code by removing the HTML and tertiary functionality. This will help you narrow down where the problem is. For example:
    #!/usr/bin/perl -w @all = split(/?/,$ENV{'HTTP_REFERER'}); $where = @all[1]; die $where;
    Just running that snippet and checking the Error_Log will let you determine if your split is running properly, if you're using the correct environment variable, if you're making your array call correctly, et cetera. Based on the output value of $where you can figure out where your (first) problem is.

  3. Environment variables are tricky. Some are only defined under certain circumstances. For example, QUERY_STRING will only be defined if there is a question mark at the end of the URL path. For example:
    A) http://www.host.com/cgi-bin/test-script.pl B) http://www.host.com/cgi-bin/test-script.pl?param=value C) http://www.host.com/cgi-bin/test-script.pl?param=value&color=blue 1: #!/usr/bin/perl -w 2: 3: warn $ENV{'QUERY_STRING'}; Line 3 returns: A) blank (null string, no data) B) param=value C) param=value&color=blue
    Keep this in mind.

  4. CGI.pm is great for dealing with different parameter values. I know you're a newbie, but it's really easy and intuitive. Here's some quick code for you:
    #!/usr/bin/perl -w use CGI; use strict; my $cgi = new CGI; # this creates a new CGI object my $where = $cgi->param('where'); warn $where;
    Now you can call this script like this: /cgi-bin/locator.pl?where=Front And 'Front' will be written to your Error_Log. Simple, right?

Mostly I've just echoed what's already been written in reply to your first post. There's not much more we can give you.

Good luck.

'kaboo

PS - If you're having all this trouble trying to do this in Perl, you're going to have a seizure trying to do it in JavaScript. 'nuff said.

Replies are listed 'Best First'.
Still Stuck
by Chady (Priest) on Dec 16, 2000 at 22:15 UTC
    well.. it seems that the server is f**ing with me... I don't know what is going on...
    I tried to debug the code by using this code
    foreach $key (sort(keys %ENV)) { print "$key = $ENV{$key}<br>\n"; }
    so I got this output:
    DOCUMENT_ROOT = /data1/virtualave.net/lezar GATEWAY_INTERFACE = CGI/1.1 HTTP_ACCEPT = */* HTTP_ACCEPT_ENCODING = gzip, deflate HTTP_ACCEPT_LANGUAGE = en-us HTTP_CACHE_CONTROL = max-stale=0 HTTP_COOKIE = p_go2id=UE5dCG1Pd76kk/ZxDmBBgw HTTP_HOST = lezar.virtualave.net HTTP_REFERER = http://lezar.org/index2.cgi?Front HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigEx +t) PATH = /usr/local/bin:/usr/bin:/bin QUERY_STRING = REMOTE_ADDR = 209.239.68.247 REMOTE_PORT = 34052 REQUEST_METHOD = GET REQUEST_URI = /index2.cgi SCRIPT_FILENAME = /data1/va/lezar/index2.cgi SCRIPT_NAME = /index2.cgi SCRIPT_URI = http://lezar.virtualave.net/index2.cgi SCRIPT_URL = /index2.cgi SERVER_ADMIN = webmaster@virtualave.net SERVER_NAME = lezar.virtualave.net SERVER_PORT = 80 SERVER_PROTOCOL = HTTP/1.0 SERVER_SOFTWARE = Apache/1.3.6 (Unix)
    as you can see, the QUERY_STRING appears blank... I don't know what is really going on, it seems like something is wrong with Virtual Avenue
    so before I go on and work on simplifying the code, I have to see what the heck is going on with the server, and their customer support is not quite satisfying

    STILL STUCK
    Chady
    http://chady.net
      Problem solved..
      I do believe that this node stops here..

      Chady
      http://chady.net