> I'm fairly good at using regexes to find things, but using them to  
> *replace* things is something I find quite difficult.  I have 
> a text file with lines like this:
> 
> <snip>
> 
> 1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
> 2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
> [...]
> 28 (28) MOLIK, ALICIA 671.00 15 .00 195.00 AUS .00
> 29 (33) MEDINA GARRIGUES, ANABEL 660.75 27 30.00 10.00 ESP 2.00
> 30 (35) KOUKALOVA, KLARA 660.75 23 16.00 20.00 CZE 2.00
> 
> </snip>
> 
> that I want to turn into a tab-delimited file.  

Well, you haven't let us know what the output is supposed to look like,
but try this for starters:

while (<DATA>) {
    my @cols =
    m/^(\d+)          #id1
      \s(\(\d+\))     #id2
      \s([\w ]+),     #lastnames
      \s(\w+)         #first name
      \s([\d\.]+)     #data1
      \s([\d\.]+)     #data2
      \s([\d\.]+)     #data3
      \s([\d\.]+)     #data4
      \s(\w+)         #country code
      \s([\d\.]+)     #data5
    /x;
    printf "%s\n", join "\t", @cols;
}

__DATA__
1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
28 (28) MOLIK, ALICIA 671.00 15 .00 195.00 AUS .00
29 (33) MEDINA GARRIGUES, ANABEL 660.75 27 30.00 10.00 ESP 2.00
30 (35) KOUKALOVA, KLARA 660.75 23 16.00 20.00 CZE 2.00


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to