in reply to Closure confusion in Tkx

Many years ago, I asked a similar question on PerlGuru. Since then, I almost never use the c-style "for". I had completely forgotten the reason. Thanks for the reminder.
Bill

Replies are listed 'Best First'.
Re^2: Closure confusion in Tkx
by LanX (Saint) on Jul 13, 2019 at 16:16 UTC
    Please note that copying to an inner declaration works
    for ( my $x = 1 ; $x < 4; $x++ ) { my $i = $x; push @cfor, sub { warn "cfor: \ti=$i \tx=$x" }; }

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice