> What I wanted was, > > sub popup_menu_factory { sub { $q->popup_menu(@_) } } > > which doesn't work.
Define 'work'. That will work as sub popup_menu_factory { sub { $q->popup_menu(@_) } } $p = popup_menu_factory() ; $popup = $p->(@popuparguments) ; But if you're expecting persistence it won't work as $p = popup_menu_factory(@popuparguments) ; $popup = $p->() ; Because you aren't storing the @_ array anyplace for it to persist them. If you write it like this: sub popup_menu_factory { my @args = @_ ; sub { $q->popup_menu(@args) } } You capture the arguments to "popup_menu_factory" in the scoped variable @args. Since you are returning a reference to an object inside this scope, the scope can't go away, so the @args variable persists until you free the reference to the anonymous sub inside it. That said, I'd want to name the routine so that people aren't writing the highly unreadable $variable->() ; But instead sub popup_menu_factory (@) { my @args = @_ ; sub menu () { $q->popup_menu(@args) } ; } ... $popup = popup_menu_factory(@arguments) ; ... $popup->menu() ; (And yes, I always put a space before a ";" - you wouldn't believe how much easier it makes spotting missing ones) Ol