|Problems? Is your data what you think it is?|
Need a better way to count input linesby Theo (Priest)
|on May 07, 2004 at 14:27 UTC||Need Help??|
Theo has asked for the
wisdom of the Perl Monks concerning the following question:
This is the second Perl script I've done from scratch and I'm havin' a ball! I'd like some constructive criticism over all and in two specific areas.
The objective is to convert an MS Word document of the company phone list to an MS Excel spreadsheet for sorting and conversion to several web pages (of differing sort orders).
The Word file is saved to a text file where each person's info is spread over 3 lines. The script pulls everything into one line per person with tabs separating each item. Having been hand entered, the data is somewhat "dirty". Most of the regexp work is cleaning linefeeds, carriage returns and the random non word characters around the valid data.
Question 1: Is there a more perlish way to count the three lines per person? (What I'm doing looks so much like C.)
Question 2: If you look at the input data for "Bo Jo Le Much" you'll see there is no space after the comma separator and there is a CR (^M) after the first name in the output. If I insert a space after the comma in the input data, the CR in the output goes away. Why?