Hi,

since Perl 5.12 you can use Each to give back the index as well:

Code:
    use v5.12;

    my @ar = ('mais', 'kirschen', 'bohnen', 'gurken');

    while(my ($index, $value) = each(@ar)) {
        say "Index: $index -> Value: $value";
    }

Outcome:
Index: 0 -> Value: mais
Index: 1 -> Value: kirschen
Index: 2 -> Value: bohnen
Index: 3 -> Value: gurken

Regards,
Wolf

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to