for %hash.kv -> my $key, $val {
say "$key corresponds to $val";
}
####
use strict;
use warnings;
{ my %lists;
sub deal {
my $aref=shift;
my $id= \$_[0];
#print $aref,$id;
$lists{$id}=$aref if (! exists $lists{$id} );
if (@{$lists{$id}}){
for(@_) {
$_=shift @{$lists{$id}};
}
return 1;
# could be extended to
# * iteration counter
# * remaining list-elements
# * a list of all of these
} else {
delete $lists{$id};
return 0;
}
}
}
$\="\n";
#--------- here we go
while (deal [1..9] => my ($a,$b,$c) ){
print $a,$b,$c;
while (deal [a=>1,b=>2] => my ($a,$b) ){
print $a,$b;
}
}
#---------
print "EXIT";
__DATA__
123
a1
b2
456
a1
b2
789
a1
b2
EXIT
##
##
while( deal {a=>1,b=>2} my($k,$v) ) {..}