Click here to get back home

How to do math inside of a regex?

 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
How to do math inside of a regex? Rossman123 11-11-2006
Get Chitika Premium
Posted by Rossman123 on November 11, 2006, 9:23 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

Posted by Brian Wakem on November 11, 2006, 9:31 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
Help with variable with regex inside. December 4, 2006, 2:05 am
Regex: Backreferences do not work inside quantifiers? March 7, 2006, 1:56 pm
Regex for finding email addresses inside text file January 27, 2005, 1:44 am
Math July 18, 2007, 9:46 pm
Math::NumberCruncher-5.00 bug January 14, 2005, 12:19 pm
Math::Knuth::DLX January 17, 2006, 3:58 pm
Help with compiling Math::GMP on AIX 5.3 September 12, 2007, 12:18 pm
More math than perl... October 5, 2007, 5:12 pm
Re: More math than perl... October 6, 2007, 9:31 am
Division/math bug in perl? February 24, 2005, 1:46 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap