exists function returns true if an array index (or hash key) has been defined, and false if it has not.
#Format: exists $ARRAY[index];
#!/usr/bin/perl
@names = qw(Tom Raul Steve Jon);
print "Hello $names[1]\n", if exists $names[1];
print "Out of range!\n", if not exists $names[5];
Related examples in the same category