in reply to checking if hashref value exists based on a dynamic array
sub deep_exists { my $hash = shift; return 0 if @_ == 0; while (@_ > 1) { $hash = $hash->{shift} or return 0; } return exists $hash->{$_[0]}; } if (deep_exists(\%hash, 'a', 't', 'etc')) { ... }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: checking if hashref value exists based on a dynamic array
by kyle (Abbot) on Aug 08, 2008 at 15:15 UTC | |
by ikegami (Patriarch) on Aug 08, 2008 at 20:32 UTC |
In Section
Seekers of Perl Wisdom