From: Matt S Trout Date: Mon, 22 May 2006 02:30:34 +0000 (+0000) Subject: nuked each() out of core with prejudice X-Git-Tag: 5.7099_04~576 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=c82ed742c266d6ad53cf3f18214d392cd6d188f7;hp=c81ae4e1a54b3016a91b61a19abfac302c21ecb7 nuked each() out of core with prejudice --- diff --git a/Changes b/Changes index b786981..272c571 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ This file documents the revision history for Perl extension Catalyst. + - nuked each() out of core with prejudice (due to lurking buglets) + - Added tests from phaylon for dispatcher precedence - Use Class::Inspector->loaded($class) instead of $class->can('can') - Added ActionClass attribute - Removed Test::WWW::Mechanize::Catalyst from Makefile.PL (circular dep) diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index c206761..99a8767 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -324,8 +324,8 @@ sub stash { if (@_) { my $stash = @_ > 1 ? {@_} : $_[0]; croak('stash takes a hash or hashref') unless ref $stash; - while ( my ( $key, $val ) = each %$stash ) { - $c->{stash}->{$key} = $val; + foreach my $key ( keys %$stash ) { + $c->{stash}->{$key} = $stash->{$key}; } } return $c->{stash}; diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index de506cb..6e46c81 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -62,15 +62,18 @@ sub finalize_cookies { my ( $self, $c ) = @_; my @cookies; - while ( my ( $name, $cookie ) = each %{ $c->response->cookies } ) { + + foreach my $name ( keys %{ $c->response->cookies } ) { + + my $val = $c->response->cookies->{$name}; my $cookie = CGI::Cookie->new( -name => $name, - -value => $cookie->{value}, - -expires => $cookie->{expires}, - -domain => $cookie->{domain}, - -path => $cookie->{path}, - -secure => $cookie->{secure} || 0 + -value => $val->{value}, + -expires => $val->{expires}, + -domain => $val->{domain}, + -path => $val->{path}, + -secure => $val->{secure} || 0 ); push @cookies, $cookie->as_string; @@ -388,13 +391,15 @@ sub prepare_parameters { my ( $self, $c ) = @_; # We copy, no references - while ( my ( $name, $param ) = each %{ $c->request->query_parameters } ) { + foreach my $name ( keys %{ $c->request->query_parameters } ) { + my $param = $c->request->query_parameters->{$name}; $param = ref $param eq 'ARRAY' ? [ @{$param} ] : $param; $c->request->parameters->{$name} = $param; } # Merge query and body parameters - while ( my ( $name, $param ) = each %{ $c->request->body_parameters } ) { + foreach my $name ( keys %{ $c->request->body_parameters } ) { + my $param = $c->request->body_parameters->{$name}; $param = ref $param eq 'ARRAY' ? [ @{$param} ] : $param; if ( my $old_param = $c->request->parameters->{$name} ) { if ( ref $old_param eq 'ARRAY' ) { diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index fae6a9a..17e4eed 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -94,10 +94,10 @@ sub prepare_headers { local (*ENV) = $self->env || \%ENV; # Read headers from %ENV - while ( my ( $header, $value ) = each %ENV ) { + foreach my $header ( keys %ENV ) { next unless $header =~ /^(?:HTTP|CONTENT|COOKIE)/i; ( my $field = $header ) =~ s/^HTTPS?_//; - $c->req->headers->header( $field => $value ); + $c->req->headers->header( $field => $ENV{$header} ); } } diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 0024009..60a166d 100644 --- a/lib/Catalyst/Engine/HTTP.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -178,8 +178,10 @@ sub run { my $sockdata = $self->_socket_data( \*Remote ); my $ipaddr = _inet_addr( $sockdata->{peeraddr} ); my $ready = 0; - while ( my ( $ip, $mask ) = each %$allowed and not $ready ) { + foreach my $ip ( keys %$allowed ) { + my $mask = $allowed->{$ip}; $ready = ( $ipaddr & _inet_addr($mask) ) == _inet_addr($ip); + last if $ready; } if ($ready) { $restart = 1;