I have a lot of XML (from an XML editor) basically thousands of characters on one line.
IW has a Pretty DCR setting that is helpful for DCRs. Does not help me.
So I wrote this:
#!/usr/iw-home/iw-perl/bin/iwperl
my $changed = 0;
my $fname = shift;
if (-B $fname)
{ print "$fname is binary - not changing\n";
exit(0);
}
open(IN, "<$fname") || die " '$fname' ($!)";
my
@text = map {$changed += s/></>\n</g; $_; }
<IN>;
close(IN);
if ($changed) {
print "Processed $fname\n";
open(OUT, ">$fname") || die " '$fname' ($!)";
print OUT
@text;
close(OUT);
} else {
print "Did not change $fname\n";
}
it puts linefeeds between ><
Not nearly as nice, but functional. Is there a better way ?