{
my @list;
sub set {
$_ = shift @list
for @_;
}
sub from (&$){
my ($c_list,$c_loop) = @_;
@list= $c_list->();
LOOP:
while (@list) {
$c_loop->();
}
}
sub loop (&){
$_[0]
}
}
sub xlast{
no warnings 'exiting';
last LOOP;
}
####
my @a=1..10; # update2
for (1..3) {
from {@a} loop {
set my ($a,$b,$c);
print "(",$a,$b,$c,")";
# no warnings 'exiting';
# last;
};
print "\n";
}
__END__
(123)(456)(789)(10)
(123)(456)(789)(10)
(123)(456)(789)(10)
####
This can be extended to take more than one element at a time:
Was: while (my($age, $sex, $location) = splice @whatever, 0, 3) { ... }
Now: for @whatever -> $age, $sex, $location { ... }
(Except the for version does not destroy the array.)
####
$SIG{__WARN__}= sub {
return if $_[0] =~ /^Exiting subroutine/;
warn $_[0];
};