1 2 3 4 5 6 7 8 9 10 11 12 13 14
my $lstlisting=0; while (<>) { my $line = $_; if (m/%DIFDELCMD\s+<\s+\\begin{lstlisting}/) { $lstlisting=1; } if ($lstlisting) { $line =~ s/%DIFDELCMD\s+<\s+//; } print $line; if (m/%DIFDELCMD\s+<\s+\\end{lstlisting}/) { $lstlisting=0; } }