in reply to Re^2: XMLin question
in thread XMLin question

I was curious if there was some way to auto-convert < to < as well as tags like this in general instead of manually doing this, from an end user perspective.

:| You don't say :/

perl -pe "%f = qw{ < &lt; > &gt; }; s{[^><]\K([><])([^\w])}{ $f{$1}$2} +g; " < in > out

Replies are listed 'Best First'.
Re^4: XMLin question
by Anonymous Monk on Feb 15, 2013 at 18:21 UTC
    naturally, untested, doesn't work :/
      I'm not surprised. \K was added in perl 5.10 but with -e perl won't use any features that are so "recent". Try "-E" instead, at least, if you have perl 5.10 or later.

      But, I don't think it will work, anyway. /([><])([^\w])/ would fix every "</" in your XML, and that just isn't right.

        I'm not surprised. \K was added in perl 5.10 but with -e perl won't use any features that are so "recent".

        That doesn't apply to regex syntax, see feature

        Anyway, I didn't test oneliner originally, and didn't try hard to fix it because I wrote xmlfixup.pl