Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Answer: Like in hashes, do we have something like exists in arrays as well.

by SuicideJunkie (Vicar)
on Jan 24, 2013 at 16:22 UTC ( #1015195=categorized answer: print w/replies, xml ) Need Help??

Q&A > arrays > Like in hashes, do we have something like exists in arrays as well. - Answer contributed by SuicideJunkie

use strict; use warnings; my @stuff = (0,1, undef); for (0..3) { print "Element $_ : " . (!exists ($stuff[$_]) ? 'Does not exist' : !defined ($stuff[$_]) ? 'is Undef' : "is '$stuff[$_]'") . "\n"; }
Gives:
>perl test.pl Element 0 : is '0' Element 1 : is '1' Element 2 : is Undef Element 3 : Does not exist

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2016-09-27 06:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (496 votes). Check out past polls.