perl -le ' $a[10] = 1; if (exists $a[2]) { print "how did that get there?\n"; } else { print "a[2] does not exist\n"; } ' a[2] does not exist