use strict; my @a; $a[1] = 'eins'; $a[10] = 'zehn'; $a[100] = 'hundert'; my $i; foreach (@a) { printf "%s %s\n", $i, $_ if $_ ; $i++; }
mit hash
use strict; my %a; $a{1} = 'eins'; $a{10} = 'zehn'; $a{100} = 'hundert'; $a{1000000} = 'million'; $a{1000000000} = 'milliarde'; foreach (sort keys %a) { printf "%s %s\n", $_, $a{$_}; }