in reply to Lexical use/no Module?
Of course there is nothing to stop you from just mangling the symbol table at runtime. It is not a specifically compile time practice. (Come on try it,.. all the cooool kids are doing it) And with a little creativity and just the right amount of insanity you could make this work.
I saw this trick in Hook::LexWrap, by TheDamian, its quite simple really and very elegant. The code would look something like this:
The magic (oooohhhh spooky) is that the variable $no_bling is lexically scoped. It is also an object instance. When the object is created in Bling->off() it unties $$. The DESTORY method of the object instance then re-tie's $$. Since DESTROY will get called at the close of the block,... whalla,.. you get lexically scoped insanity.use Bling; $x = $$; ## Bling Bling as before { my $no_bling = Bling->off(); $y = $$; ## no Bling Bling } $z = $$; ## Bling Bling as before
If you dont like the Bling->off() syntax, then you could try something witty with the indirect object syntax. buh_bye Bling or something like that. (although you can't use "no" cause perl will confuse it with the real "no")
Of course, no one in their right mind would do such a thing. No no,.. never,... never ever,.. no ,.. stop,.. dont make me,.. nooooooooooo......
-stvn
Disclaimer: In no way does this post consitute an endorsement of the practice of mangling perl's global variables. Bad,.. very very Bad.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Lexical use/no Module?
by Stevie-O (Friar) on Jan 29, 2004 at 03:52 UTC | |
by stvn (Monsignor) on Jan 29, 2004 at 04:19 UTC | |
|
Re: Re: Lexical use/no Module?
by QwertyD (Pilgrim) on Jan 29, 2004 at 19:55 UTC | |
by stvn (Monsignor) on Jan 29, 2004 at 22:20 UTC |