Click here to get back home

assembling a signed integer from bytes

 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
assembling a signed integer from bytes Steve 01-08-2005
Posted by Steve on January 8, 2005, 1:54 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 Jim Gibson on January 10, 2005, 11:08 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
Reading fields and their values from a signed PDF form April 1, 2006, 3:03 pm
char->integer, integer->char commands November 21, 2005, 10:24 am
bytes and characters - how to decode? August 21, 2004, 2:19 am
How do I parse certain "bits" out of bytes? May 4, 2005, 12:46 am
Converting 4 bytes to a float May 8, 2007, 8:35 pm
high and low bytes of a decimal May 20, 2008, 12:28 pm
Matching a variable number of bytes April 13, 2006, 1:31 pm
Archive::Zip problem - bytes being added/changed by zip->contents() July 4, 2006, 4:17 am
0 + 1 not an integer? August 4, 2004, 7:56 am
integer fail ... July 28, 2005, 3:35 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap