{ # open an anonymous block to form the closure my $foo; my $bar; sub fubar { # code that uses $foo and $bar # goes in here } } # end of the closure