"Fromm, Marc" wrote: > Hi > > I created a script that reads a file and attaches a string infront of each read in >item. When the file is saved with the changes though, each item has a blank line >between the next item. The original text document does is single sapced. > > Original tesxt file > item1 > item2 > item3 > > Saved text file > string item1 > > string item2 > > string item3 > > I think what his happening is when the items are read in lots of white space is >attached to the end of the string. > > Is there a way to remove only trailing white space, from a string, but retain white >spaces with in the string? > thanks, > > Marc
Hi Mark, The safest apraoch for such situations is to use chomp and then add a newline to each line in the output. The chomp function is a smart little bugger--it eats trailing newlines if they exist, but will otherwise leaves the string untouched. Of course, if you want your output to come out exactly as it was in the file, then just leave it alone and pass it through: while <FILE> { print $_; } Likewise, if you are manipulating the lines but not in ways that would truncate the newline at the end, you can just pass them through. That is a bit risky, though, so it's probably better to just chomp on input and restore the newline on output. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]