Here is a simpler example
See also Tutorials: Variable Scoping in Perl: the basics, Coping with Scoping , Mini-Tutorial: Perl's Memory Management, Lexical scoping like a fox#!/usr/bin/perl -- use strict; use warnings; my @closures ; for( 1 .. 3 ){ my $me = $_; # lexical $me push @closures, sub { print "You got $me\n"; # lexical $me }; } $_->() for @closures; shift(@closures)->(); $_->() for @closures; __END__ You got 1 You got 2 You got 3 You got 1 You got 2 You got 3
In reply to Re^6: Clearing anonymous Tk widgets
by Anonymous Monk
in thread Clearing anonymous Tk widgets
by murrayn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |