http://www.perlmonks.org?node_id=146140

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

I have a very strange problem with a large cgi program that I'm developing on a windows machine with ActiveState perl. I have a hash loaded with the values of the browser's cookie so that the many modules that make up the cgi program can easily access the user's state. When the user turns off cookies in the browser, this hash still exists, it just contains no keys.

It works just great when the user sends a cookie to the server, but something breaks when no cookies are sent. When I use this hash in a boolean test ( ie. $hash{key}>3 ) the process hangs with no error output. It just sits there doing nothing and taking up no cpu cycles. When I move this program to a linux server with the same version on perl it works just great whether or not the user has cookies on. I'm hopeing this is a bug in the windows port of perl, but I'm not going to hold my breath. Any thoughts would be appreciated.

PS: Sorry that I can't post any code, but it's too large and really wouldn't help much anyway.

Replies are listed 'Best First'.
Re: Mysterious ActiveState Perl Hangs
by simon.proctor (Vicar) on Feb 18, 2002 at 13:32 UTC
    I can't comment on the bug itself but why don't you use the exists() function on your hash key prior to your logic?

    Something like (untested):
    unless(exists $hash{$key}) { # Do stuff return; } if($hash{$key} > 3) { # Other stuff }
Re: Mysterious ActiveState Perl Hangs
by cLive ;-) (Prior) on Feb 18, 2002 at 19:04 UTC
    Time for you to say a few hail marys - or drink a few bluddy marys - I can never remember which...
    use strict; use warnings; use CGI; my $q = new CGI; # when assigning $hash{'key'} = $q->cookie('key') || '0';
    That narrows down the field.

    cLive ;-)

    --
    seek(JOB,$$LA,0);