On 02/06/2012 04:58 PM, Parag Kalra wrote:
On Mon, Feb 6, 2012 at 1:14 PM,<sono...@fannullone.us> wrote:
For example, do I really need three foreach loops?
You can get rid of third ForLoop for sure.
you don't actually lose the third loop. grep is an implied loop.
STATE: foreach my $state (keys %states) {
if ($state eq $customers_state) {
foreach (@{$states{$customers_state}}) {
use a named variable there.
my @zips = $_;
that assigns an array ref to @zips and not the list of zips. you need to
dereference it. and you don't need a temp var as you can do that in the
grep itself.
$match = 'yes' if grep /$customers_zip/, @zips ;
last STATE;
why the last call there? it means the double loop only executes one time.
uri
}
}
}
print $match;
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/