1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# Remove parts of code enclosed in %latex/%endlatex tags $latexonly = 0; while(<>) { $latexonly = 1 if /^%latex/i; $latexonly = 0 if /^%endlatex/i; if($latexonly) { if(/^%!(.*)/) { print $1; } } else { print; } }