Click here to get back home

qr// doesn't handle m modifier?

 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
qr// doesn't handle m modifier? adam 09-01-2006
Posted by adam on September 1, 2006, 1: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 Michele Dondi on September 1, 2006, 5:14 pm
Please log in for more thread options
On 1 Sep 2006 10:57:38 -0700, adam@irvine.com wrote:

>The following program doesn't do what I expected. The second and third
>"print" statements print, but the first one doesn't. It looks as
>though when the match operator uses a regular expression constructed
>with qr//, the "m" modified that should have been stored in the regular
>expression is ignored. Did I do something wrong, or is this a bug in

(?imsx-imsx) => check perldoc perlre


Michele
--
->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Posted by xhoster on September 1, 2006, 6:06 pm
Please log in for more thread options
> On 1 Sep 2006 10:57:38 -0700, adam@irvine.com wrote:
>
> >The following program doesn't do what I expected. The second and third
> >"print" statements print, but the first one doesn't. It looks as
> >though when the match operator uses a regular expression constructed
> >with qr//, the "m" modified that should have been stored in the regular
> >expression is ignored. Did I do something wrong, or is this a bug in

I get the same behavior as you do, using 5.8.8.

>
> (?imsx-imsx) => check perldoc perlre

I don't think his question is where the behavior is described, but
rather why the actual behavior does not seem to match the description that
perlre gives.

I'm rather stumped on that, too.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

Posted by anno4000 on September 4, 2006, 6:04 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 Paul Lalli on September 4, 2006, 7:19 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
Prematch ($`) and the m//g modifier March 9, 2006, 8:09 pm
Why doesn't it evaluate in RE using "e" modifier ?? January 2, 2008, 5:50 am
s replace p modifier April 14, 2008, 7:13 pm
/e modifier to s///; short "1 liner" ? December 7, 2007, 1:26 pm
GLOB vs IO::Handle January 11, 2005, 1:49 pm
handle to /dev/null? September 20, 2005, 3:58 pm
How to handle large variable October 28, 2004, 8:50 pm
FAQ 4.46: How do I handle linked lists? October 28, 2004, 11:03 pm
file handle problem December 4, 2004, 7:29 pm
file handle problem December 4, 2004, 10:42 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap