Nik has asked for the wisdom of the Perl Monks concerning the following question:

I use the following code to greet people that visits my webpage if they already have a cookie stored by my website in their pc. The problem now is that $cookie{xronos} has inside it spaces an because of that it apperars in the webpage when i print it like this: "Sun%20May%2030%2001%3A55".

What can i do about it?

And also if you see something else that is wrong in this piece of code or you have a better way of writing this please let me know. Thanks.
if ( $file = param("choice") ) { open(FILE, "../data/texts/$file") or die $!; @data = <FILE>; close(FILE); $data = join("", @data); } elsif ( $ENV{HTTP_COOKIE} ) { @cookieArray = split( ';', $ENV{'HTTP_COOKIE'} ); foreach ( @cookieArray ) { ($cookieName, $cookieValue) = split ( '=', $_ ); $cookie{$cookieName} = $cookieValue; } $data = "Καλώς ήρθες " .$host. "! Χαίρομαι ειλικρινά που σε ξαναβλέ +πω!\n" . "Τελευταία φορα ήρθες εδώ ως " .$cookie{host}. "!\n" . "Αυτή είναι η " .$cookie{xronos}. " φορά που επισκέφτεσαι την σ +ελίδα μου και χαίρομαι πολύ που την βρίσκεις ενδιαφέρουσα!\n" . "Ποιό κείμενο θα ήθελες να μελετήσεις αυτήν τη φορά ?!?"; } elsif ( !$ENV{HTTP_COOKIE} ) { $data = "Καλώς ήρθες " .$host. "! Ανοίγοντας το παραπάνω drop-down +menu επέλεξε το κείμενο που θα ήθελες να διαβάσεις..."; }

The Devil Is In The Details!

Replies are listed 'Best First'.
Re: something about cookies and spaces
by antirice (Priest) on May 29, 2004 at 22:19 UTC
    Nik, you're using param(), so I imagine you're using CGI. If that's the case, then why don't you just import cookie() and check it? It'll do your splitting and decode URL-encoded values for you.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

    A reply falls below the community's threshold of quality. You may see it by logging in.