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 | |
|
Re^2: Canon concerning coderef calls?
by ihb (Deacon) on Nov 17, 2004 at 09:24 UTC |