PinkeyNBrain
IS-IT--Management
Found the following:
This code generates:
Where is the -1 element coming from?
Code:
print "Index of first element $[\n";
print "pre 0 exists\n" if (exists $arr[0]);
print "pre -1 exists\n" if (exists $arr[-1]);
push(@arr, 'foo');
print "post 0 exists\n" if (exists $arr[0]);
print "post -1 exists\n" if (exists $arr[-1]);
print "arr elements $#arr\n";
Code:
Index of first element 0
post 0 exists
post -1 exists
arr elements 0