#!/usr/bin/perl # # ---------------------------- # -------- FilterSpace ------- # ---------------------------- # # A perl script for removing extra space from a # document. Feed it a text file and it'll return just the # text without redundant space. # This script was written by William Stearns # (wstearns@pobox.com). I havent decided about the license # yet, but it'll probably be GPL later... # Copyright 1997 by William Stearns. No employer has # any rights to this program over the rights granted by # the GPL as this was developed on personal time. # $line = ; while ($line ne "") { $line =~ s/\r//g; # remove CR from dos text $line =~ s/[ \t]{2,}/ /g; # Compresses whitespace $line =~ s/^[ \t]+//g; # Kill leading space $line =~ s/[ \t]+$//g; # Kill trailing space if ( ($line ne "\n") && ($line ne "\r") && ($line ne "\r\n") ) { print $line; } $line = ; }