http://qs1969.pair.com?node_id=577166


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.