On Mon, 28 Jul 2003, McKown, John wrote:

> Is there a simple way to strip blanks from all the lines in a file? What I
> am doing is downloading members from my various PDSes. Some of these member
> contain the "standard" sequence number in columns 73-80. I am using Perl to
> strip these off. After stripping off the sequence numbers, I would like to
> strip off any resulting trailing blanks. My current Perl script looks like:
>
> #!/usr/bin/perl
> while(<>) {
>         chop;
>         s/(.{0,72}).*/\1/;
>         $new1 = reverse($_);
>         $_ = $new1;
>         s/ *(.*)/\1/;
s/ +$//; # or something like.
>         $new = reverse($_);
>         print $new,"\n";
>         }
>
> I admit that I'm a tyro Perl person. I'm a legacy mainframer. I am more used
> to assembler and REXX.

The dollar in my regex represents end of line. If I have it right, it
will change one or more consecutive spaces at the end of line to null.

>

--


Cheers
John.

Join the "Linux Support by Small Businesses" list at
http://mail.computerdatasafe.com.au/mailman/listinfo/lssb
Copyright John Summerfield. Reproduction prohibited.

Reply via email to