Click here to get back home

Parsing two files and comparing the first fields..

 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
Parsing two files and comparing the first fields.. clearguy02 11-28-2007
Posted by clearguy02 on November 28, 2007, 6:12 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
Comparing XML files August 8, 2005, 6:22 pm
Comparing two files January 15, 2008, 3:55 pm
Comparing two files April 7, 2008, 6:07 pm
Comparing huge XML Files February 23, 2005, 1:14 am
Comparing 2 XML files need some suggestions please April 15, 2005, 7:14 am
comparing modification times of files September 13, 2006, 11:10 am
Diff files with regex comparing May 13, 2007, 11:40 am
?Merging files based on first two comma delimited fields? September 16, 2005, 11:41 am
compare 2 data files and extract fields for matched lines December 27, 2007, 11:25 am
Newbie - Reading a file with delimited fields, storing first two fields in a hash November 7, 2005, 4:52 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap