#
# Basic Perl to fix the "IMGnnn.HTM" files generated by PowerPoint
# when making HTML pages from a portrait-mode presentation.
#
# Run this in the directory containing the files to fixed:
#
# > Perl FixPort.pl
#
# (no arguments required)
#
# All files of the form IMGnnn.HTM, imgnnn.html, etc. will have
# the strings "HEIGHT" and "WIDTH" swapped.
#>>>>> CHANGE BY MIKE LISA - "img" --> "sld"
#
# The original files are renamed to "filename.org", e.g, 
#    IMG012.HTM --> IMG012.HTM.org
#
# Note that *all* occurrences of these parameters will be swapped.
# This is not a problem for the stuff generated by PowerPoint, but
# could be a problem if you have other files named "IMGnnn.HTM"
# containing those parameters in that directory.
#
#########################################################################
#
# Get list of all files with given pattern "IMGnnn.HT*" :
#
opendir(DIR, '.');
#@files = grep( /img[0-9]*\.HT/i, readdir(DIR) );
@files = grep( /sld[0-9]*\.HT/i, readdir(DIR) );
closedir(DIR);

$NumFiles = @files;                                     # Gets length of @files
print "There are $NumFiles files to modify: @files\n";


@ARGV = @files;        # Prime the <> operator
$^I = ".org";          # Tell it to make back-up of original files

while (<>)             # Loop on the file list
   {                                   
     s/HEIGHT=/BLIGHT=/i;              # Swap HEIGHT and WIDTH    
     s/WIDTH=/HEIGHT=/i;               #    through intermediate string
     print;
    }                                  # end-of-loop added by Mike Lisa 
print "Starting second loop\n";
@ARGV = @files;        # Prime the <> operator
while (<>)                             # gotta do the height-->width thing TWICE!!!
   {
     s/WIDTH=/HEIGHT=/i;               #    through intermediate string
     s/BLIGHT=/WIDTH=/i;               #       'BLIGHT'
     print;                            # Sends output to ARGVOUT == "new" file of old name
   }


