http://www.perlmonks.org?node_id=25918
Category: Utility Scripts
Author/Contact Info Intrepid
Description:

Please use caution!

I have found out from external sources that in XML, whitespace outside of tags can be significant, and that although the present version of PPM does not mind how my script changes <CITE>ppm.xml</CITE>, a future version may. It might be better, therefore, not to use this script.

The Perl Package Manager (with ActivePerl) writes to a file named ppm.xml each time a module is installed using PPM. It doesn't add nice whitespace to the file, however, resulting in a mess if one ever needs to or wants to (out of curiosity) go in there and see what has happened before. This little (slightly "anal" :) utility script can be called from the very end of <CITE>PPM.bat</CITE> (another file that comes standard with the installation of ActivePerl) by adding the line:

CALL fixPPMXMLfile

to the file below the lines that match this:

__END__ :endofperl

at the end of the batchfile. This kicks off your cleaner which adds some whitespace to make more human-friendly a file which, it is to be admitted, is ordinarily only machine-read.

#!perl -wi.bak
# fixPPMXMLfile

$ARGV[0] = 'D:/ActivePERL/site/lib/ppm.xml';

while ($line=<>)  {
    $line =~ s#(</PACKAGE>)(<PACKAGE NAME=)#$1\n\n$2#;
    print $line;
}

#########################
#  run `pl2bat' on this and: either place in your
#  PATH, or supply a full path specification when
#  you CALL it.
#########################
Replies are listed 'Best First'.
Re: ppm.xml made more human-friendly
by data64 (Chaplain) on Mar 31, 2001 at 06:37 UTC
    It's a nice idea. But if you just want to look at it you could just open it in IE and it will format it for you. There are also some fine freeware XML editors that will do the same.
      That's fine. Different people have different work-styles and priorities. Opening IE just to view a file of this sort, instead of looking at it in my always-running text editor where I am doing all my other work, is preferable to me. If a person was not running a machine with lavish resources, too, they might prefer to avoid firing up yet another hoggish Windows application just to look at a simple list of what's been installed to their Perl?

         Intrepid

        Indeed! My NTEmacs HTMLhelper/XML mode likes your script, and for notepad or it's ilk there is little else I can find & use!

        HTH
        --
        idnopheq
        Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.