Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^4: Hacking Perl Codeby Discipulus (Canon) |
on Apr 09, 2014 at 11:39 UTC ( [id://1081636]=note: print w/replies, xml ) | Need Help?? |
Dear LanX, i only meant, as explained in the update of the original post that my solution only executes any BEGIN block and no more, while with perl -c -d:TraceUse script.pl all the BEGIN UNITCHECK CHECK blocks are executed. I was wrong (so thanks for your question), because my code also executes any END blocks and even other UNITCHECK already present, because those blocks run LIFO. Here some code to demonstrate the concept. With a script called test_of_executed_code.pl as follow: You can now compare the two solutions: while with my script you'll see: The only way i found to prevent the END blocks to be executed is to change, in the UNITCHECK part of the original script, exit; with an ugly exec qq(perl -e "exit"); that produces: But, considering the LIFO aptitude of the UNITCHECK blocks, i can do it better and change eval $begin.$content; with eval $content.$begin; producing: Thanks for the opportunity to learn something more. L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|