BEGIN {
our %ENGINES;
}
use strict;
each %ENGINES;
__END__
Global symbol "%ENGINES" requires explicit package name at - line 5.
Execution of - aborted due to compilation errors.
####
my %hash;
@hash{a..f} = 10..15;
sub a {
my $a_count;
while( my ($k,$v) = each %hash) {
print "$k => $v\n";
$a_count++;
}
$a_count++;
}
sub b {
my $b_count;
while( my ($k,$v) = each %hash) {
$b_count++;
print "$k => $v ($b_count out of ", a(), ")\n";
}
}
b()
__END__
c => 12
a => 10
b => 11
d => 13
f => 15
e => 14 (1 out of 5)
c => 12
a => 10
b => 11
d => 13
f => 15
e => 14 (2 out of 5)
c => 12
a => 10
b => 11
d => 13
f => 15
e => 14 (3 out of 5)
...
####
my %hash;
@hash{a..f} = 10..15;
my $count;
while(my ($k,$v) = each %hash) {
$count++;
print "$k => $v ($count of ", scalar(keys %hash),")\n";
}
__END__
e => 14 (1 of 6)
e => 14 (2 of 6)
e => 14 (3 of 6)
e => 14 (4 of 6)
e => 14 (5 of 6)
e => 14 (6 of 6)
e => 14 (7 of 6)
...
(runs forever)