Click here to get back home

multiple changes on multiple lines

 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
multiple changes on multiple lines Dave 04-02-2005
Posted by Dave on April 2, 2005, 9:42 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 Gunnar Hjalmarsson on April 2, 2005, 8:06 pm
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
Multiple lines in output! please some help! April 11, 2005, 6:38 pm
Can I Grep multiple lines?? February 10, 2006, 12:01 pm
matching over multiple lines November 20, 2006, 8:39 pm
Insert Multiple Lines after a Specified Line -- Please Help! May 4, 2007, 4:05 pm
replace multiple lines in a file with Perl December 15, 2004, 11:48 pm
matching HTML expression across multiple lines May 10, 2006, 4:31 pm
how can I print multiple lines without escaping '$' and other characters? September 29, 2006, 8:38 pm
Can perl find strings over multiple lines? November 19, 2006, 11:52 pm
assigning multiple hash values to multiple variables May 2, 2006, 7:55 pm
Update multiple lines in a flat file from array September 4, 2004, 12:55 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap