-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 04 Sep 2003 06:37:57 -0700, LoneWolf wrote:

> I have about 12 files that I am pulling for a SCO box to a RedHat box, FTP. 
> THe files from the SCO box are poorly formatted with extraneous whitespace
> (sometimes as much as 30 or more) before and after the text.  I need to
> parse all of the files I DL and put them into a new file with "_nice" added
> at the end.
> 
> The files are all pipe-delimited, so I don't have a problem separating the
> fields, I just am not sure how to make it remove all extra whitespace.  It
> needs to keep all Space in the fields "        the    description   of   the
>  file        " should still be readable as "the description of the file"
> 
> Any help with code examples?  I have been looking through a beginning book
> and my old code and have come up nil.

- From your example it appears that you want to remove all whitespace from
the beginning, and end, and duplicates from inside. You can achieve this
easily:

my $text = '   the   description of   the   file   ';
for($text) {
        s/^\s+//;
        s/\s+$//;
        # Perhaps its more effecient to put this next line first?
        s/\s+/ /g;
}

Also, check "perldoc -q space".

 - Brian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/V1ohiK/rA3tCpFYRAsGpAJ0XWKLjN9+7MYBnfeFz1g/DBWsqtgCg80v1
COz0Otn5XsqmO3D/ErXKkjQ=
=EgAZ
-----END PGP SIGNATURE-----



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to