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: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/
