in reply to How to extract the filenames in an array

 @name1=$namearr[0]; is the same as saying  $name1[0]=$namearr[0]; so there is nothing in  $name1[2] to print out.