Click here to get back home

Matching a variable number of 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
Matching a variable number of bytes mikeharrison56 04-13-2006
Get Chitika Premium
Posted by Matt Garrish on April 16, 2006, 3:57 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 xhoster on April 16, 2006, 9:16 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
string matching specific number of times September 29, 2005, 6:51 pm
Using a variable in a matching string November 21, 2006, 1:18 pm
variable number of arguments to bind_columns December 5, 2007, 7:58 am
Simplify Variable Number of Regex Groups June 14, 2007, 11:14 pm
Variable interpolation and m in regular expression matching January 22, 2008, 8:42 am
string matching inside file and save in a variable June 6, 2007, 5:16 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

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap