in reply to Making variables visible between calls.
sub create_f { my $func = shift; return sub { $func->("xpto"); } } my $function = create_f( sub { my $var = shift; print ">> $var <<\n" } );
It's technically possible using dynamic scoping (local), but that increases coupling. What I presented is a much better alternative.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Making variables visible between calls.
by ambs (Pilgrim) on Dec 12, 2008 at 18:12 UTC | |
by ikegami (Patriarch) on Dec 12, 2008 at 18:13 UTC |