Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Making my own control flow structure

by jbert (Priest)
on Oct 09, 2006 at 13:15 UTC ( [id://577166] : note . print w/replies, xml ) Need Help??


in reply to Making my own control flow structure

The only way I can think of to do this in perl is with a source filter. This allows you to effectively re-write the perl to do whatever you want (think lisp macros, but without the regularity of lisp s-exps, hence more complex).

In your case, you could introduce a new keyword (say 'tif' for tracked-if) and rewrite:

tif(xxx) { some; perl; code; }
to
if(xxx) { some; perl; code; } else { print some; print perl; print code; }
The CPAN Filter::Simple module looks like a good place to start, but I don't really have any experience writing these things, to be honest.