package Example::Module; use strict; { my $value; # this lexical variable stores a subroutine that is only # accessible from within this block. my $add = sub { $value += $_[0] }; sub accumulate { $add->($_) for @_ } sub printvalue { print $value, $/ } } 1;