in reply to Re^3: Calling func named in string
in thread Calling func named in string
My goal was to type the list of names once
Oh, well, in that case, how about not hand populating the list at all? Consider:
use strict; use warnings; my @names = sort grep {/^TestSub/} keys %main::; my @FuncList = map {$main::{$_}} @names; $main::{TestSub2}(); $FuncList[0](); sub TestSub1 { print "TestSub1\n"; } sub TestSub2 { print "TestSub2\n"; }
That depends on having a searchable pattern for your sub names, but means you don't have to maintain the list at all. Another hundred subs to add? Just add them to the code and run off grinning!
|
---|