in reply to how can i get the index value of array during runtime

If you want the index of the array, then either use the C-style for loop:

for (my $i = 0; $i <= $#array; $i++) { # index is in $i # element is in $array[$i]; }

Or iterate over the indexes rather than the elements:

foreach (0 .. $#array) { # index is in $_ # element is in $array[$_]; }

Update: Changed $i to $_ in comments in the second code example. Thanks to arkturuz for spotting the error.