in reply to Detect undefined subroutines
#!perl use strict; use warnings; my $x = shift; my $sub_name = $x ? 'foo' : 'bar'; eval "*$sub_name = sub { print \"Hello!\n\" };"; foo();
If the script is passed in a true value, then it will run correctly. If it's passed in a false value, it will not run correctly. But, you want Perl to know what to do before it's been given all the information it might need.
Now, I wouldn't mind seeing an additional optional option added to strict that requires all subroutines, but not methods, to be defined by the time CHECK is complete. But, that's another story.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Another Story (Detect undefined subroutines)
by diotalevi (Canon) on Sep 17, 2004 at 18:24 UTC | |
by ihb (Deacon) on Sep 17, 2004 at 21:33 UTC |