in reply to run-time syntax checking
Of course this simple piece of code could be improved, since a comment at the end of $code could break things.eval "sub { $code }"; die "Compilation failure: $@" if $@;
You call then invoke &$closure (or $closure->()) when you want to actually execute the code.my $closure = eval "sub {\n$code\n}";
--
integral, resident of freenode's #perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: run-time syntax checking
by abell (Chaplain) on Jan 31, 2003 at 13:55 UTC | |
by diotalevi (Canon) on Jan 31, 2003 at 19:49 UTC | |
|
Re^2: run-time syntax checking
by Aristotle (Chancellor) on Jan 31, 2003 at 13:12 UTC | |
by Pardus (Pilgrim) on Feb 01, 2003 at 14:17 UTC | |
by Aristotle (Chancellor) on Feb 01, 2003 at 16:28 UTC | |
by Pardus (Pilgrim) on Feb 01, 2003 at 16:42 UTC | |
by diotalevi (Canon) on Feb 01, 2003 at 16:59 UTC | |
|