On Fri, Jun 27, 2008 at 12:26 AM, Erasmo Perez <[EMAIL PROTECTED]> wrote:

>
> a,b,.,.,.,.,.,.,.
> b,c,d,.,.,.,.,.,.
> e,f,g,h,.,.,.,.,.
> i,j,k,l,m,.,.,.,.
>
> and so on
>
> My problem: how could I get rid of the trailing points and commas, so
> the output CSV file could get following neat format (without the
> trailing points and its commas separators):
>
> a,b
> b,c,d
> e,f,g,h
> i,j,k,l,m
>

Hello,

Follow your sample data, you may try:

use strict;

while(<DATA>) {
   s/(\,\.)+$//;
   print;
}

__DATA__
a,b,.,.,.,.,.,.,.
b,c,d,.,.,.,.,.,.
e,f,g,h,.,.,.,.,.
i,j,k,l,m,.,.,.,.


The output is:

a,b
b,c,d
e,f,g,h
i,j,k,l,m

-- 
Jeff Peng - [EMAIL PROTECTED]
http://home.arcor.de/mailerstar/jeff

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to