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.
In reply to Re: Making variables visible between calls.
by ikegami
in thread Making variables visible between calls.
by ambs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |