in reply to Re^3: Calling a hash member
in thread Calling a hash member

I think you meant

my %ThingsToDo = ( firstTask => sub { my $pkg = shift; $pkg->prepare(@_) }, ); ... $ThingsToDo{firstTask}->($project);

But that's much more complex than required, and would involve lots of redundancy (sub { my $pkg = shift; $pkg->XXX(@_) }.

Replies are listed 'Best First'.
Re^5: Calling a hash member
by geekphilosopher (Friar) on Dec 14, 2006 at 02:42 UTC
    Thanks a lot - I figured this was a good opportunity for a code ref, but I don't actually have much experience using them. Next time I'll have a go at a few sample programs before I offer (dubious) advice.
      A coderef would have been fine here except for the whole $project being dynamic bit.