# My actual implementation { my $object; sub setobject { $object = shift; } # Each of these routines has access to the shared # lexical. Enclosing this whole section in a block # prevents the lexical from being used in other scopes sub start_handler { ... } sub char_handler { ... } sub end_handler { ... } } # What is probably better though there is a heck of a lot # of space to move this around. I implemented this as a # wrapper over some named subroutines and passed the shared # variable in. You can really do this however you feel. sub get_handlers { my $object; return { start_handler => sub { start_handler(\@_,\$object) }, end_handler => sub { end_handler(\@_,\$object) }, char_handler => sub { char_handler(\@_,\$object) } } }