Click here to get back home

Getting Perl to ignore Letters when calculating numbers.

 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
Getting Perl to ignore Letters when calculating numbers. bass150db 03-30-2005
Posted by bass150db on March 30, 2005, 9: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 John Bokma on March 31, 2005, 6:55 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
regular expression consecutive numbers or letters November 1, 2006, 11:10 am
Perl for calculating an expression. July 23, 2008, 12:36 am
Perl Regex Question: how to translate only the leading letters of a line July 10, 2004, 4:52 pm
Calculating time of employee session from the log date/time stampusing perl May 24, 2005, 5:55 pm
How to convert string to an expression in PERL or calculating numerical string November 23, 2005, 5:03 am
calculating a list.. June 28, 2005, 4:51 am
ps2eps.pl Hangs on "Calculating Bounding Box" February 8, 2006, 7:45 am
Calculating values of a 2d array by comparison of 2 strings December 15, 2006, 9:48 am
Help: Reverse Letters May 2, 2008, 10:44 am
Matching words and letters December 8, 2004, 11:33 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap