in reply to Exists and arrays

The element $dow[5] exists in the array since you've treated it as an lvalue and assigned to it when you did $dow[5]=undef the second time you checked for existence. Why the first time checking for (exists $dow[5]) returns you false is obviously because it had nothing assigned to it and that there's no implication if $dow[6] does exist that $dow[5] has to automatically exist.
Being defined is not related to existence, a variable can exist but it doesn't necessarily mean it is defined as is the case when you want to flush out a variable value.Another thing, a return value of undef can indicate many things, as operation failure, end of file...etc

Exists checks whether a variable is existing in the array, that is, it has a value associated with it as a result of assignment (i.e. $dow[0]=undef), this is clearly indicated in Perl documentation for Functions, check out both defined and exists functions to decloud the confusion

#!/usr/local/bin/perl use strict; my @dow=(); #array initialization is different from indexes initiali +zation $dow[0]=undef; $dow[6]= "sat"; for(my $i=0; $i <=6;$i++){ if(!(defined($dow[$i]) || exists($dow[$i]))){print "\$dow[$i] +\t not defined\n";} if(exists($dow[$i]) && !defined($dow[$i])){ print "\$dow[$i]\t +exists\t not defined\n"; } if(exists($dow[$i]) && defined($dow[$i])){ print "\$dow[$i]\te +xists\t defined\n" ;} }

Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.