Click here to get back home

perl -pe substitution

 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
perl -pe substitution Asim Suter 01-18-2008
Get Chitika Premium
Posted by Asim Suter on January 18, 2008, 5:43 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

Posted by Abigail on January 18, 2008, 5:57 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
Perl Substitution April 28, 2006, 4:47 am
substitution in perl February 1, 2007, 3:10 am
parametrical substitution in perl October 31, 2005, 9:24 am
Command substitution in perl October 7, 2006, 11:41 am
need help for text substitution using Perl October 20, 2006, 4:51 pm
Perl substitution working on some machines but not others? November 21, 2006, 7:02 am
Perl Regex substitution: replace nth occurrance April 9, 2008, 2:44 am
substitution May 25, 2005, 1:41 am
What is the RHS of a substitution? May 21, 2006, 3:24 am
Substitution November 6, 2008, 1:17 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap