Click here to get back home

Perl coding style question

 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 coding style question Michael Vilain 01-04-2005
Get Chitika Premium
Posted by Michael Vilain on January 4, 2005, 3:47 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 Anno Siegel on January 5, 2005, 12:01 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
coding style and performance August 18, 2005, 2:18 pm
Coding in Perl August 10, 2007, 1:37 am
A little help on perl coding.. November 21, 2007, 3:14 pm
Calling a module style question March 4, 2007, 1:03 pm
vi "power tools" for Perl coding? February 14, 2005, 4:00 am
Problem in Enforcing utf8 coding for output May 25, 2007, 8:48 pm
Coding Conventions and Speech: No Punctuation, Renaming Operators etc... July 31, 2005, 2:11 pm
Perl style array in C? April 9, 2005, 9:28 pm
cpp-style include for perl? January 22, 2006, 2:35 pm
perl style: can I combine two steps into one? February 4, 2005, 12:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap