barvin has asked for the wisdom of the Perl Monks concerning the following question:
eval "require My::Object::$subclass"; my $obj = My::Object::$subclass->new(@params);
This works fine, but as I edit subclass.pm and introduce syntax errors, they of course can't be caught at compile time. However I would have expected them to be caught at runtime when the require executes, but they aren't.
What actually happens is that every subroutine including and after the one where the syntax error is, just goes missing and the program complains "Undefined subroutine..." when it first tries to call one of the missing subs. I can confirm the loss of the subroutines in the debugger with 'S' - the sub in the required module where the syntax error is and every sub after it is not listed in the current namespace. The Perl Programming book is silent about the syntax checking behavior of the require command.
Thanks for any help.
Barry
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Runtime syntax checking of a 'require'ed module
by ikegami (Patriarch) on Jul 03, 2008 at 01:10 UTC | |
|
Re: Runtime syntax checking of a 'require'ed module
by Joost (Canon) on Jul 02, 2008 at 23:53 UTC | |
|
Re: Runtime syntax checking of a 'require'ed module
by BrowserUk (Patriarch) on Jul 02, 2008 at 23:37 UTC | |
|
Re: Runtime syntax checking of a 'require'ed module
by Your Mother (Archbishop) on Jul 02, 2008 at 23:56 UTC | |
by ikegami (Patriarch) on Jul 03, 2008 at 01:14 UTC |