in reply to fetch url

Click on a URL where? Obtain the value where? (i.e. what is the relationship between the software recording the click, the software making the http request, and the URL being requested (is it your site? various different 3rd party sites? a site that is generated by one of the afore mentioned pieces of software?)

A form is used in an HTML document when you want the user to enter some data - pretty much anytime you don't want to give them a list of choices (as they can be represented by regular links). From your description it doesn't sound like you need that.

CGI.pm is a nice, mature bit of software. While you can read $ENV directly, using the CGI.pm interface will probably be more elegent for basic functions, and protect you from silly mistakes in less trivial functions (such as parsing query strings). So use CGI.pm.

Replies are listed 'Best First'.
Re^2: fetch url
by perlboer (Acolyte) on May 27, 2005 at 11:24 UTC
    Thank you for the reaction.
    Sorry if it isn't clear. (first time you know)

    Let I put it this way:
    I have a "start_page" with +/- 100 urls on it.
    When I hit one of these url's, i would like to go to the url
    (could be www.perlmonks.org), and I would like to log in a file that "www.perlmonks.org" was viewed.
    input to load the "start_page" (.conf file):

    desc,url,hitcounts
    nu,http://www.nu.nl,0
    cvs,http://www.cvshome.org/,1
    perl tutorial,http://www.steve.gb.com/perl/index.html,4

    Than i'm able to count with that url.
    Than i'm able to add 1 to "hitcounts".

      Don't worry about it. You clearly put some effort into describing the problem, and given that you are in the Netherlands, I'm guessing English isn't your first language. Its laziness that most people hate around here. We don't mind helping you refine a question if you put the effort in.

      First I would suggest that you use a Real Database instead of a CSV file. I would suspect that using a CSV file could lead to file locking and efficiency issues. That said, you can use the DBI interface to CSV which looks like it solves the file locking problem. I've never used it myself, so I can't be certain it would work nicely.

      As for the actual problem - when the user clicks on their link, their browser will go to it. If that link goes to a different server, the browser won't send any information back to your server so you can't know that they clicked on that link.

      The solution is to have the link point to your server, log the request, and then perform an HTTP redirect.

      To do this you have your script change:

      <a href="http://www.cvshome.org/">CVS</a>

      To:

      <a href="my.cgi?gotoSite=1">CVS</a>

      Where 1 is a unique identifier for the link. You then look up that entry in the database (in my.cgi), log the visit, then redirect (the CGI.pm perldoc tells you how) to the URL stored in your database.

      You should use identifiers and database lookups rather then that URL itself for two main reasons. First, it prevents people using your domain to cloak their dodgy URL, and second it saves you from the effort of having to URL Encode and HTML Encode the string when you generate the webpage.

        Your feedback is overwhelming, thank you for that

        After a couple of days searching i didn't know that i should have look for a syntax like you mentioned
        I was searching the wrong direction
        Thank you also for the extra tips
        So i have a lot of homework now

        Must I close this question in some way, or do i have to do something else to keep things surveyable ?

        Kind regards,
        The Perlboer