Search code examples
perloperatorssubroutine

Is there a Perl subroutine for exist and defined?


I use exists and defined in if statements all the time

if (exists($a->{b}) and defined($a->{b})

is there a subroutine that does both of these at the same time?

UPDATE:
Seems I didn't give very good example code. For a better question and matching answer check out checking-for-existence-of-hash-key-creates-key.


Solution

  • defined(...) can only be true when exists(...) is true, so the answer to your question is that the subroutine is called defined.