On Mon, Feb 6, 2012 at 1:14 PM, <[email protected]> wrote:
> For example, do I really need three foreach loops?
>
>
>
You can get rid of third ForLoop for sure.
use strict;
use warnings;
my %states = (
AL => [ '350','351', ],
AK => [ '995','996', ],
AZ => [ '850','851', ],
AR => [ '716','717', ],
);
my $customers_state = 'AZ';
my $customers_zip = '850';
my $match = 'no' ;
STATE: foreach my $state (keys %states) {
if ($state eq $customers_state) {
foreach (@{$states{$customers_state}}) {
my @zips = $_;
$match = 'yes' if grep /$customers_zip/, @zips ;
last STATE;
}
}
}
print $match;