You're right! I posted before I realized. But thanks to all who responded. I can do exactly what I need!
-----Original Message----- From: Mark Anderson [mailto:[EMAIL PROTECTED] Sent: Thursday, March 06, 2003 5:47 PM To: Carrara, Greg; [EMAIL PROTECTED] Subject: RE: trying to match variable names You probably should have started a new thread for this discussion. > I'm trying to write a script that reads a file line by line and if the line > contains a space it puts quotation marks around it and writes it to another > file. I mostly have this working except that in the case of the lines that > contain the space it puts the quotation mark at the beginning of the next > line. My guess is that > print OUTFILE ($line); > also feeds a CR. Is there a way around this? My guess is that the last character of $line is a newline character. I have cleaned up indentation on your code so that it is readable, and sure enough, you are pulling a line from INFILE and placing it in $line, and so it still has the newline on the end. perldoc -f chomp unless (open(INFILE, "accounts.txt")) { die ("Cannot open input file accounts.txt.\n"); } unless (open(OUTFILE, ">nospace.txt")) { die ("Cannot open output file nospace.txt.\n"); } $line = <INFILE>; while ($line ne "") { if ($line =~ / +/) { print OUTFILE ('"'); print OUTFILE ($line); print OUTFILE ('"'); # instead of the above three lines I would use: print OUTFILE ("\"$line\""); # or: print OUTFILE ('"'.$line.'"'); # depending on what you think is clearest } else { print OUTFILE ($line); } $line = <INFILE>; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]