[Petal] [PATCH] Petal::Hash::Var error on undef + misc
Steve Purkis
spurkis at mkdoc.com
Wed Jul 9 15:51:59 BST 2003
Hi all,
As the functionality introduced in my previous patches doesn't seem to
have made it into the main distro, I've produced another patch for
Petal which implements the main point of my previous patches -- a user
controllable flag for error on undefined variables -- without the
performance hit (see below).
The flag can be set as such:
$Petal::Hash::Var::ERROR_ON_UNDEF = 0 || 1;
Though arguably it should be a class/instance var of the processor:
my $tmpl = Petal->new->error_on_undef( 0 || 1 );
I don't mind implementing that if people prefer it.
The patch also has some better error reporting when you try to access
vars you shouldn't. And because I've been extremely lazy, it includes
extra tests that were copied over from the last patch. The more the
merrier, I say.
The same benchmark script is included so you can all see I'm not on
crack:
% perl t/benchmark.pl
Templates Processed /s
Machine: 400MHz PPC 1.7 GHz x86
v0.96: 66.26/s 308.36/s
Patched: 63.74/s 295.07/s
This indicates roughly a 4% decrease in performance, most likely due to
the extra error reporting. If that's not livable, please let me know
and I'll rewrite it in assembler ;-).
Regards,
-Steve
More information about the Petal
mailing list