I don't get the meaning of this:
if( defined @user_geg[0..$#user_geg] ) { }
Now lets see what it means.
- 0..$#user_geg creates a list of integers from 1 to 27 (in this case). OK.
- @user_geg[0..$#user_geg] return an arrayslice consisting of elements 1..27 of the array user_geg. By my book this is the same as @user_geg. Hmmm not so good...
- defined @user_geg (leaving out the 0..27 part for now) is meaningless:
perldoc -f defined says: Use of "defined" on aggregates (hashes and arrays) is deprecated.. Not OK!
What you probably mean is "if there are any elements in the array 'user_egg' then ..." which can be expressed as
if (@user_geg) { }
See - much simpler.
Your original question as to why you have to add the -1 is probably answered by the meaninglessness of defined @user_geg.