in reply to How can I call subroutines in an array
It's hard to tell, but you're calling them when you think you're putting them into the array -- that is, at the @procs = (&a1, &a2) line. The solution to this problem is references, as discussed in perlref and perlreftut. As follows:
use strict; use warnings; sub a1 { print("a1\n"); } sub a2 { print("a2\n"); } my @procs = (\&a1, \&a2); foreach (@procs) { $_->(); }
perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'
|
---|
In Section
Seekers of Perl Wisdom