in reply to Embedding a mini-language for XML construction into Perl
I liked this meditation. However, there's one thing I didn't like: the eval call in define_vocabulary, which is unneccessarry.
Let me show the way to do the same without eval.
sub define_vocabulary { no strict "refs"; my($elems, $attrs) = @_; for (@$elems) { my $name = $_; *{$_} = sub(&) { _elem($name, @_) }; } for (@$attrs) { my $name = $_; *{$_ . "_"} = sub($) { _attr($name, @_) }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Embedding a mini-language for XML construction into Perl
by tmoertel (Chaplain) on Nov 19, 2005 at 18:27 UTC | |
by stvn (Monsignor) on Nov 19, 2005 at 20:42 UTC | |
by ambrus (Abbot) on Nov 19, 2005 at 18:42 UTC | |
by Aristotle (Chancellor) on Nov 22, 2005 at 16:48 UTC |