in reply to Making variables visible between calls.

You could put the variables into some other package which exists just to hold them e.g.
#!/usr/bin/perl use strict; use warnings; sub create_f { my $func = shift; return sub { $MyBucket::var = "xpto"; &$func; } } my $function = create_f( sub { print ">> $MyBucket::var <<\n" } ); $function->();