Well, the non-sub way could look like this:
my $hash_has_non_undef = do { my $found; until($found or not (undef, m
+y $v) = each %hash) { $found = defined $v } $found };
I mean, that's the way we had to do it in Pascal. Stupid boolean flag variables all over the place because they wouldn't let us exit blocks. {grin}
Doh! As I'm staring at this, I realize the $v can do double duty.
my $hash_has_non_undef = do { my $v; until($v or not (undef, $v) = eac
+h %hash) { $v = defined $v } $v };
But that's optimized for Golf, not for maintenance. Ick.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply. |