good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Silencing specific warnings when executing coderef?by LanX (Saint) |
on Mar 23, 2014 at 12:56 UTC ( [id://1079437]=perlquestion: print w/replies, xml ) | Need Help?? |
LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi Is it possible to externally disable warnings within the scope of an already compiled code-block? That is without manipulating $SIG{__WARN__}³ or to deparse and reevalute the code? Maybe using some B magic?
motivationI'm playing around to mimic the for LIST -> variables feature of Perl6¹, but with more syntactic sugar, than splice or natatime can provide. One of my attempts looks like this and kinda works... implementation: <Reveal this spoiler or all in this thread> model:
...but while using loop-control statements like last works (amazing²) it throws a warning which needs to be silenced. I could refrain to adding new pseudo statements like xlast() but this break in orthogonality would confuse too much. Manipulating the sig-handler adds to much overhead, using B::Deparse is somehow risky, cause it's not bug-free. I think this is of general interest for those playing around with syntactic sugar. :)
Cheers Rolf ( addicted to the Perl Programming Language)
update¹) from perlcabal
²) ...and disturbing ... and scaring ... and Perl! ;-) ³) for completeness
update2Put initialization of @a to the start to show that the from-loop reinitializes each time, even if broken with last.
Back to
Seekers of Perl Wisdom
|
|