# doesn't reference anything outside the scope of the subroutine scope sub not_a_closure { my $i; $i++; return $i } # references a package variable, not a lexical variable our $global; sub also_not_a_closure { $global++; return $global; } # a closure -- references a lexical outside the scope my $lexical; sub a_closure { $lexical++; return $lexical; } # anonymous closure generator -- references a new variable each time sub closure_generator { my $fresh_lexical; return sub { $fresh_lexical++; return $fresh_lexical; } }