Click here to get back home

Clean string

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Clean string kjhjhjhjadsasda 08-14-2006
Get Chitika Premium
Posted by kjhjhjhjadsasda on August 14, 2006, 3:14 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Posted by John W. Krahn on August 14, 2006, 3:20 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Similar ThreadsPosted
Clean Quarantine Script August 19, 2004, 12:15 pm
regex to clean path October 18, 2004, 1:34 pm
How to clean up this ugly code? November 22, 2007, 6:21 pm
Repeatedly parsing a file to "clean" it. September 10, 2004, 11:20 am
Clean out accents in French names May 17, 2005, 11:44 pm
Perl script to clean up file -- Dont know if it can be done September 22, 2004, 9:16 am
Counting occurances of string A in string B, and adding it to string B August 3, 2004, 1:53 pm
Perl ActiveX: A VBA string passed to my control is treated as a doubel-quoted string October 9, 2006, 4:03 pm
How to convert string to an expression in PERL or calculating numerical string November 23, 2005, 5:03 am
Search a Text File for a String, Return String to Function July 29, 2006, 12:19 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap