in reply to Re^2: One liner to Check and undef hash elements (shortcircuiting)
in thread One liner to Check and undef hash elements
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}my $hash_has_non_undef = do { my $found; until($found or not (undef, m +y $v) = each %hash) { $found = defined $v } $found };
Doh! As I'm staring at this, I realize the $v can do double duty.
But that's optimized for Golf, not for maintenance. Ick.my $hash_has_non_undef = do { my $v; until($v or not (undef, $v) = eac +h %hash) { $v = defined $v } $v };
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: One liner to Check and undef hash elements (shortcircuiting)
by Aristotle (Chancellor) on Apr 16, 2003 at 11:53 UTC |