Leser: 26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
my @arr = @$db; for (0..3) { $id = $arr[$_]->{id}; $dbserv = $arr[$_]->{dbserv}; } ## oder # C-like for (my @arr = @$db, my $i=0; $i<=3; $i++) { $id = $arr[$_]->{id}; $dbserv = $arr[$_]->{dbserv}; } ## oder # als Array-Splice for (@$db[0..3]) { $id = $_->{id}; $dbserv = $_->{dbserv}; }
1
2
3
4
5
6
7
8
9
10
11
12
for (my $i=1; $i<=3; $i++) { print $i }
foreach (my $i=1; $i<=3; $i++) { print $i }
my @array = (1..3);
for (@array) { print }
foreach (@array) { print }
my %hash = (1,1,2,2,3,3);
for (sort keys %hash) { print }
foreach (sort keys %hash) { print }