in reply to Why doesn't exist work with hash slices?
What would it even mean? Should it check if they all exist, or if any exist?
And that's why it doesn't exist. It's not clear what that should do, it's not clear what it does by looking at it, it's not something that's commonly needed, and it's easily done with slightly more code.
If you want to check if all of the elements exist, you can use
all { exists( $h{ $_ } ) } @keys
If you want to check if any of the elements exist, you can use
any { exists( $h{ $_ } ) } @keys
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why doesn't exist work with hash slices?
by ysth (Canon) on Sep 21, 2025 at 16:46 UTC | |
by 1nickt (Canon) on Sep 22, 2025 at 10:50 UTC | |
by choroba (Cardinal) on Sep 22, 2025 at 12:48 UTC | |
by LanX (Saint) on Sep 22, 2025 at 13:57 UTC | |
by 1nickt (Canon) on Sep 22, 2025 at 14:25 UTC |