Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Using filepath method to identify an .html page

by blue_cowdawg (Monsignor)
on Jan 22, 2013 at 17:33 UTC ( #1014742=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Using filepath method to identify an .html page
in thread Using filepath method to identify an .html page

      ( .htaccess gives my script the absolute path for that .html page)

How's that?

I've shown you a simple hash function to convert an arbitrary string into a four digit number. It's up to you to go from there...


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg


Comment on Re^5: Using filepath method to identify an .html page
Re^6: Using filepath method to identify an .html page
by Nik on Jan 22, 2013 at 17:48 UTC
    And i'am sure it will work great!

    Here is the .htaccess directives responsible to pass the actual .html page's absolute path to counter.py (please do not get mad at me, i'am trying to code your solution into python code, which is easier to me)
    RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?superhost\.gr$ RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?htmlpage=%{REQUEST_FILEN +AME} [L,PT,QSA]
    But my friend, why bother creating a custom function?

    Wouldn't something like the following work as intended?
    pin = int( htmlpage.encode("hex"), 16 ) % 10000
          (please do not get mad at me, i'am trying to code your solution into python code, which is easier to me)

      Oh... I won't get mad at you. If you want to code this in Python, I don't do snakes. You're on your own. Why in the world would you ask about Python code in a Perl forum?


      Peter L. Berghold -- Unix Professional
      Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
        Perl is great, its just too tough for me. Python is more clear.
        I need your help

        1. to see in regards of "specification" if this was indeed possible.
        2. just wanted 1-line of Perl code to see it working, and then write the same 1-line in Python.

        Wouldn't something like the following work as intended WITHOUT custom function?
        pin = int( htmlpage.encode("hex"), 16 ) % 10000
        Can you please explain the differences to what i have posted opposed to your coding:
        foreach my $ltr(@ltrs){ $hash = ( $hash + ord($ltr)) %10000;
        I want to understand this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014742]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2014-10-23 19:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (128 votes), past polls