Q&A > arrays > Like in hashes, do we have something like exists in arrays as well. contributed by SuicideJunkie
my @stuff = (0,1, undef);
print "Element $_ : " .
(!exists ($stuff[$_]) ? 'Does not exist' :
!defined ($stuff[$_]) ? 'is Undef' :
Element 0 : is '0'
Element 1 : is '1'
Element 2 : is Undef
Element 3 : Does not exist
Non-existent; I don't have TV
Non-existent; my TV doesn't have/need a remote
Under my control; I watch alone
Under the control of whoever shouts loudest
Under the control of whoever gets it first
One of many, and the TV has a mind of its own
Results (593 votes),