[HRPM] new and improved
Troy E. Webster
twebster at pcs.cnu.edu
Thu May 11 15:57:41 CDT 2000
Thanks everyone for the tips...I used(stole) some ideas and made my
original code a little more robust. A little prettier and as a C++ guy, a
little more readable for me as well.
here's the updated script:
#!/usr/local/bin/perl
######################################################
# code.pl
#
# This is a simple script which will process html files
# and remove annoying blank lines in an html page's
# source code which are generated by software packages
# such as Cold Fusion. Hand-editing these pages is
# tedious. Also will strip out carriage returns from DOS
# files to use in UNIX.
#
# ERROR: none
#
# NOTE: This script will work on pages generated by
# a UNIX platform-specific application OR a
# page which was created in Windows. (there
# are different "newlines" associated with each)
#
# AUTHOR: Troy Webster May 2000
######################################################
die "Usage: code.pl [filename]\n" if (@ARGV < 1);
foreach (@ARGV)
{
print "Processing file: $_\n";
open (FH, "<$_") or die "unable to open file $_ .\n";
my @lines = <FH>;
close(FH);
$get = "\r";
$sub = undef;
open (OUT, ">$_") or die "unable to open file.\n";
foreach $line(@lines)
{
$line =~ s/$get/$sub/g; # gets rid of the \r 's
if ($line eq "\n")
{
print "removing blank line.\n";
chop $line;
}
print OUT $line;
}
close(OUT);
}
exit;
___________________________________________________________________________
- improvise, adapt, overcome -
www.pcs.cnu.edu/~twebster/
---------------------------------------------------------------------------
More information about the Norfolk-pm
mailing list