is there a way to (temporarily) disable packages?
let's say I wanted to create a DSL for SQL, this partial clause would be legal in Perl
sub WHERE(&;$); WHERE { a IN [1,2,3] or b LIKE '%abc%' };
and the block would be parsed as indirect method syntax
'IN'->a([1, 2, 3]) or 'LIKE'->b('%abc%');
so I'd need to define packages IN and LIKE to simulate binary operators when executing the BLOCK
DB<198> {package LIKE; sub AUTOLOAD { my ($field) = $AUTOLOAD =~ m/\ +w+::(\w+)/; print "$field @_" }} DB<199> field LIKE '%abc%' field LIKE %abc%
so far so good ... but is there a possibility to "disable" the package outside of the block's scope?
The best thing I came up was redefining AUTOLOAD dynamically before and after executing the block to provoke a runtime error
deleting the stash entry for the package in %main:: produced strange problems, probably because of some kind of cashing...
any ideas?
at hindsight %INC and @INC might be useful ... (?)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
In reply to [DSL] disabling packages in Perl? by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |