[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: each vs. foreach problem
From: kevin <kevin () alchemyfx ! com>
Date: 1999-08-31 21:23:58
[Download RAW message or body]
I'm having problems using 'each' on keys and values of a hash as opposed to
using 'foreach'.
Running Apache in single-server mode (httpd -X), every third reload returns
0 - which is false - when I use 'each'.
use Constants; #** %COOKIE_FIELDS defined in Constants **#
#** cookie hash sent in as reference **#
sub CookiesNotDefined
{
my $rhCookie = shift;
my ($key,$val);
while (($key,$val) = each %Constants::COOKIE_FIELDS)
{
return 1 if (!defined $$rhCookie{$val});
}
return 0;
}
If I use 'foreach' as follows, it works every time.
sub CookiesNotDefined
{
my $rhCookie = shift;
my ($key,$val);
foreach $key (keys %Constants::COOKIE_FIELDS)
{
$val = $Constants::COOKIE_FIELDS{$key};
return 1 if (!defined $$rhCookie{$val});
}
return 0;
}
So, what's mod_perl doing to 'foreach' that it is doing for 'each'?
Please help - this seems like a weird one.
Thanks
kevin
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic