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

Will the below program solve your issue??
@array =qw (34 56 78 9); $index = 0; foreach (@array) { print "$index \t $_ \n"; $index++; }

Replies are listed 'Best First'.
Re^2: how can i get the index value of array during runtime
by GrandFather (Saint) on Mar 02, 2007 at 10:59 UTC

    If an "index" is required use $index as the identifier. If a count is required you need to pre-increment the value or set it to 1 initially.

    Yes, I know it is trivial sample code that doesn't matter, but good habits are worth acquiring. And distinguishing between a (1 based) count and a (0 based) index is a habit well worth acquiring!


    DWIM is Perl's answer to Gödel
      Gladly accepted your point ..
      :)