I suspect you have some special character un your line or some extra spaces. So to delete the special characters, you must know the character (display it in hexa) if it is some extra spaces , s/\s\s+/\s/g before your print will replace two spaces or more with only one. Yves
-----Original Message----- From: Mario Ortiz [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 8:21 PM To: [EMAIL PROTECTED] Subject: How do I chop the extra space in this file and add commas, Hi Everyone I have a file I thought I parsed correctly but it seems to have extra spaces and added lines with spaces. I need to get rid of these spaces. I have use the chop and chomp function but it does not help any. Is there any other way to do this and add a comma to separate the "acctnumber and system columnsin each of the lines. See code I used and the sample of the data I am working with. #!/usr/bin/perl -w use strict; my $systest = 'c:\acmsublink\convertline\line_sys.txt'; open (FILE, "<$systest"); while (<FILE>) { s/\"+//g; chomp($_); print "$_\n"; } close (FILE); sample data below: The "acctnumber" is the numbers and the text is the "system" column. One example below of extra spaces is acctnumber "110115" where the ("110115","DALE BORO POLICE) and the next line below it has blank lines. How can I get rid of those extra spaces? One other problem is not able to add commas as a separator between the "acctnumber" ands "system" on all the lines of the file. The file has to be pushed into another database so I need to correct the spaces and add a comma or another delimiter between the number and the text. 110115 TEMP NOTE: WHEN DISPATCHING ON THIS ACCOUNT, PLEASE TELL POLICE, FIRE, OR 110115 EMS THAT THIS ADDRESS IS LOCATED IN DALE BOROUGH!! MDB "ACCTNUMBER,SYSTEM", "467-6754", "535-1158", "*467-0180", "110115","DALE BORO POLICE 110115 TEMP NOTE: WHEN DISPATCHING ON THIS ACCOUNT, PLEASE TELL POLICE, FIRE, OR 110115 EMS THAT THIS ADDRESS IS LOCATED IN DALE BOROUGH!! MDB 110115 EXPIRES: 08/24/10 110115 " "629-6837", "120354", "479-2756","TEMP NOTE: BECAUSE OF NOISE AT STATION, TALK BUTTON MUST BE HELD DOWN A 479-2756 FEW SECONDS LONGER THAN NORMAL! AFTER DISPATCHING BETWEEN 479-2756 12:00 MIDNIGHT AND 5:00 AM CONTACT JIM BOXLER FIRST AT 479-2756 266-8300, THEN THE RADIO STATION (2ND) AT 255-4186! Thanks, Any help would be appreciated!! Mario _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
