Perl - reading a cookie and comparing it to a file

Discussion in 'Programming' started by Edmunds, Jan 6, 2007.

  1. #1
    I am a complete Perl newb, so cansomeone help me out here :(

    Basically, I have two cookies - id and hash. I need to compare them to a file, the id matches the file name, and the hash is the content of the file. I know in PHP this can be done like this:

    $compare = FALSE;
    $base = '/home/user/files/';
    if (isset($_COOKIE['id']) && isset($_COOKIE['hash']) && file_exists($base.$_COOKIE['id']) && file_get_contents($base.$_COOKIE['id']) == $_COOKIE['hash'])
        $compare = TRUE;
    
    PHP:
    How do you do this in Perl?
     
    Edmunds, Jan 6, 2007 IP