I don't think there is one. You can maintain a counter for this purpose
though.

my $counter;
for (@answer) {
        #do something ...
        print "On element index $counter\n";
        $counter++;
}

John (Ex OUP...)

-----Original Message-----
From: KAVANAGH, Michael [mailto:[EMAIL PROTECTED]]
Sent: 27 February 2002 16:26
To: '[EMAIL PROTECTED]'
Subject: iteration default variable


Hi there,

This is probably a simple one...

in a loop like this:

for (@answer) {
        #do something ...
}


I understand that for each iteration of the loop, $_ contains the value of
$answer[current iteration].
But is there a default variable I can use to get the current index value?

Can't seem to find the answer anywhere... any ideas would be helpful.

Thanks everybody for contributing to this list... I find it useful.

Thanks
Mike Kavanagh




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to