in reply to Canon concerning coderef calls?

Store the code ref itself, not the names in your list.

use warnings; use strict; my @list = (\&one, \&two, \&three); for (0 .. $#list) { &{$list[$_]}($_); } sub one { my $number = shift; print "Sub $number reporting for duty.\n" } sub two { my $number = shift; print "Sub $number reporting for duty.\n" } sub three { my $number = shift; print "Sub $number reporting for duty.\n" }

Replies are listed 'Best First'.
Re^2: Canon concerning coderef calls?
by jobi (Scribe) on Nov 15, 2004 at 19:51 UTC
    Alas, in the specific project I am working on (not the example code) the list is not for me to create, just to use.

    Still, thank you for your wisdom.
    jobi
Re^2: Canon concerning coderef calls?
by ihb (Deacon) on Nov 17, 2004 at 09:24 UTC

    my @list = (\&one, \&two, \&three);

    my @list = \(&one, &two, &three);
    :-)

    ihb

    See perltoc if you don't know which perldoc to read!
    Read argumentation in its context!