./perl/test/closures2.pl

download original
#!/usr/bin/perl -w


my @subs;

for my $i (1..10) {
    push @subs, sub { print "value: $i\n"; };
}


foreach my $sub (@subs) {
    $sub->();
}

  
back to test

(C) 1998-2017 Olaf Klischat <olaf.klischat@gmail.com>