Click here to get back home

can Perl Sort do this, unix sort breaks on it (muliple spaces as demiliter)

 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
can Perl Sort do this, unix sort breaks on it (muliple spaces as demiliter) colin_lyse 02-02-2005
Posted by colin_lyse on February 2, 2005, 6:08 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 Tore Aursand on February 3, 2005, 3:13 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
Re: A Sort Optimization Technique: decorate-sort-dedecorate August 30, 2006, 4:32 pm
sort with Perl .. September 21, 2006, 9:51 am
perl sort September 22, 2006, 3:22 pm
Perl program help to sort of 'pad name xy' file March 18, 2005, 12:23 pm
Question re Conway's "Perl Best Practices" - Sort::Maker May 3, 2006, 9:30 pm
[Q]: How to sort first abc, then 123? March 12, 2005, 7:16 pm
sort? May 24, 2007, 1:02 pm
sort March 7, 2008, 10:03 pm
Odd sort() problem September 29, 2004, 10:59 am
FAQ 4.52: How do I sort an array by (anything)? October 25, 2004, 5:03 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap