Click here to get back home

extracting records to an associative array

 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
extracting records to an associative array gioindo 09-13-2005
Posted by gioindo on September 13, 2005, 3:41 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 John W. Krahn on September 14, 2005, 12:56 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
associative array help June 2, 2006, 12:31 pm
Getting associative array from a hash July 7, 2005, 7:10 pm
Quick Associative Array Question December 5, 2005, 11:23 am
Generate an associative array from a file February 28, 2008, 8:59 am
Re: how to generate an associative array and count frequency? December 25, 2007, 6:13 pm
Help: Reading file and creating an associative array August 21, 2008, 3:50 pm
Complex Records help September 1, 2004, 4:47 am
finding existing records November 8, 2005, 6:09 pm
Hashes of Records -- who's smarter than me? December 5, 2005, 11:20 pm
Need help sorting fixed length records January 5, 2005, 9:02 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap