Sorry guys for the wrong input here : I had actually written it with the $ sign in place i.e. for($i=0;$i<@array;$i++) { open(FILE,"$array[$i]") or die "Could not open file :$!"; # do something close(FILE); } This program hangs in this part. I tried the same thing using : for (@array) { open(FILE,"$_") or die " Could not open file :$! " ; # do something close(FILE); } This works fine. Can't understand why the upper one doesn't work . Any comments about this.