in reply to "No strict refs" will be the death of me
1) You really can't. If you have a string, and you want to call a function of that name, or reference a variable of that name, etc., that's a soft reference. strict 'refs' doesn't allow you to use soft references.
2) It's *not* a subroutine reference--that's the problem. You're trying to use a string, the name of the routine, as a reference. You're de-referencing it:
Which says, use $_ as a subroutine reference. But it's not a subroutine reference. Hence the error message.&$_()
You can either do no strict 'refs' (which you should keep in the smallest scope possible), or you can actually take a reference to the subroutine, and use that. I'd prefer the latter:
Now obviously, this doesn't do exactly what your code does, but the point of it is just for example purposes.my @routines = ( \&Routine, \&Option, ); $_->() for @routines;
|
|---|