in reply to Re^2: fetch url
in thread fetch url

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.

Replies are listed 'Best First'.
Re^4: fetch url
by perlboer (Acolyte) on May 27, 2005 at 14:19 UTC
    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

      You're very welcome.

      No, you don't need to do anything to close a question (although a feature allowed people to mark questions as resolved has been suggested in the PerlMonks Discussion section in the past).