"Joe Discenza" <[EMAIL PROTECTED]> graced perl with these words
of wisdom: 

> You seem to have a pretty good picture of your data; why not turn
> that into a regex completely, instead of doing it piecemeal? 
>  
> /(\d+)\s+\((\d+)\)\s+([A-Z\s]+),\s+([A-Z]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+
> ([A-Z]{3})\s+(\S+)/ 
>  
> and have a replace section that strings together all your captures
> with tabs between: 
>  
> s/.../$1\t$2\t$3\t$4\t$5\t$6\t$7\t$8\t$9\t${10}/
 
I'd like to thank everybody who came up with suggestions.  One thing I 
forgot to point out is that there are also people with whitespace in their 
*given* names, which seems to make things even more problematic 
(backtracking and all that).

Somebody off-list gave me the suggestion not of using a regex, but of 
splitting each line on the \s characters, and then manipulating arrays 
with pop and shift and reverse.  That's something that I'm decidedly more 
able to handle, although I have a question -- when I used this bit of 
code:

<snip>

$transfer[2] = scalar @line; # @line only has the names left
   for $x (0 .. 8) {
   print FILETO "$transfer[$x]\t";
   }
   print FILETO "\n"
}

The results were as follows:

<snip>

1       (1)     2       3380.00 16      .00     49.00   USA     .00
2       (2)     2       3206.00 17      .00     .00     BEL     .00     
3       (3)     2       2851.00 19      .00     .00     FRA     1.00    

[...]

</snip>

I had to amend the code to add an if/else clause for the $x=2 case:

$transfer[2] = scalar @line;
   for $x (0 .. 8) {
   if ($x == 2) {
      print FILETO "@line\t";
      }
   else {
  print FILETO "$transfer[$x]\t";
   }
   }
   print FILETO "\n"
}

In order to get it to work.  Any ideas why?

-- 
Ted <fedya at bestweb dot net>
Oh Marge, anyone can miss Canada, all tucked away down there....
--Homer Simpson

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to