in reply to array element as foreach iterator

You can have it like this, with some syntactical constraints:

sub forache { for my $v (1..@_-2) { $_[0] = $_[$v]; &{$_[-1]}(); } } my $k; forache $k, ("greetings, ", "all\n"), sub{ print $k; }; my @a = ("hello, ", "<name>", "\n"); forache $a[1], ("james", "andy", +"bob", "david"), sub { print @a; };