Your question has been answered, this time. However it is possible that it is not the answer you want. This is because you have not given any code. It is likely that there are many areas that we can help you with even in what may seem to be a trivial piece of code. The following code is my take on what you are doing. If your actual code is very much different than this please post it so that we may highlight any other areas of concern.
# always use strictures (the following two lines) use strict; use warnings; my @array = qw(key1 key2 key3 key4); my %hash = (key2 => undef, key4 => 'The goods', key5 => 'More goods'); for my $key (@array) { next if ! exists $hash{$key}; # Skip if the key is not used in the + hash next if ! defined $hash{$key}; # Skip if the key exists, but is un +defined print "The value for '$key' is '$hash{$key}'\n"; last; }
Prints:
The value for 'key4' is 'The goods'In reply to Re: loop question...
by GrandFather
in thread loop question...
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |