##
sub list_iter {
my @list = @_;
return sub {
return 0 if !@list;
$_[0] = shift(@list);
return 1;
};
}
my $iter = list_iter('a', 1, '', 0, undef, -1);
while( $iter->( my $next ) ) {
print( $next // '[undef]', "\n" );
}
####
a
1
0
[undef]
-1