<?xml version="1.0" encoding="windows-1252"?>
<node id="991371" title="Re^6: Clearing anonymous Tk widgets" created="2012-09-03 03:08:59" updated="2012-09-03 03:08:59">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
&lt;p&gt;Here is a simpler example&lt;c&gt;
#!/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
    };
}
$_-&gt;() for @closures;
shift(@closures)-&gt;();
$_-&gt;() for @closures;
__END__
You got 1
You got 2
You got 3
You got 1
You got 2
You got 3
&lt;/c&gt;See also [Tutorials]: [id://66677|Variable Scoping in Perl: the basics], [id://520303|Coping with Scoping] , [id://803515|Mini-Tutorial: Perl's Memory Management], [id://213855|Lexical scoping like a fox]</field>
<field name="root_node">
990930</field>
<field name="parent_node">
991367</field>
<field name="reputation">
0</field>
</data>
</node>
