Click here to get back home

Converting "’" to an Apostrophe?

 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
Converting "’" to an Apostrophe? maria 02-27-2008
Get Chitika Premium
Posted by Tad J McClellan on February 28, 2008, 7:36 pm
Please log in for more thread options

> $xml =~ s/’/'/sg;


The s///s modifier makes dot in your pattern match a newline.

It is a no-op when your pattern does not have a dot in it.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Posted by Petr Vileta on February 28, 2008, 8:42 pm
Please log in for more thread options
Tad J McClellan wrote:
>
>> $xml =~ s/’/'/sg;
>
>
> The s///s modifier makes dot in your pattern match a newline.
>
> It is a no-op when your pattern does not have a dot in it.

I have seen it many times but my book say some bit different.

<cite>
Larry Wall, Tom Christiansen & Randal L. Schwartz
Programming in Perl (Czech translation, 1997)

Chapter 2: Basic program parts, page 74

Modifiers:
....
s Work with string as with single line.
</cite>

Nowhere any word about dot in regexp. I wrote many s/// for strings containing
\n and where wasn't be any dots in pattern and on some server this work
without /s modifier but on other not. Maybe somewhere was be Perl 5.0 or
older, I don't know. But by me is better to write "noop" modifier instead of
to write not functional regexp/replacement.

--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to <petr AT practisoft DOT cz>


Posted by A. Sinan Unur on February 28, 2008, 9:57 pm
Please log in for more thread options

> Tad J McClellan wrote:
>>
>>> $xml =~ s/&#x2019;/'/sg;
>>
>>
>> The s///s modifier makes dot in your pattern match a newline.
>>
>> It is a no-op when your pattern does not have a dot in it.
>
> I have seen it many times but my book say some bit different.
>
> <cite>
> Larry Wall, Tom Christiansen & Randal L. Schwartz
> Programming in Perl (Czech translation, 1997)
>
> Chapter 2: Basic program parts, page 74
>
> Modifiers:
> ....
> s Work with string as with single line.
> </cite>

In the mean time, here in 2008, in the docs shipped with Perl 5.10

perldoc perlop

s Treat string as single line. (Make . match a newline)

Sinan

--
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.rehabitation.com/clpmisc.shtml>


Posted by Gunnar Hjalmarsson on February 28, 2008, 10:41 pm
Please log in for more thread options
A. Sinan Unur wrote:
> In the mean time, here in 2008, in the docs shipped with Perl 5.10
>
> perldoc perlop
>
> s Treat string as single line. (Make . match a newline)

Great, that's a clarification I wasn't aware of.

Hopefully, in the future (Perl 5.12?), "perldoc perlop" will contain a
useful explanation of the /m operator as well. Or at least a reference
to "perldoc perlre".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by Peter J. Holzer on March 1, 2008, 5:15 am
Please log in for more thread options
> A. Sinan Unur wrote:
>> In the mean time, here in 2008, in the docs shipped with Perl 5.10
>>
>> perldoc perlop
>>
>> s Treat string as single line. (Make . match a newline)
>
> Great, that's a clarification I wasn't aware of.

You never read perldoc perlre? It has always explained the exact meaning
of the s and m modifiers (at least since 1995 or so - I haven't used
perl before that).


> Hopefully, in the future (Perl 5.12?), "perldoc perlop" will contain a
> useful explanation of the /m operator as well. Or at least a reference
> to "perldoc perlre".


The latter is there since at least perl 5.6.0 (in the paragraph before
the options). In perl 5.10, it's now a paragraph of its own (instead of
just one sentence in a paragraph) at the end of the qr/STRING/msixpo
section.

        hp


Similar ThreadsPosted
regular expression help with apostrophe March 14, 2005, 7:31 pm
Converting XML to CSV June 8, 2006, 10:48 am
Help converting sed script June 25, 2005, 12:03 pm
converting list to an array October 29, 2004, 3:10 pm
converting perl to sed/ C shell ? January 15, 2005, 8:29 pm
having issues using awk and/or converting to perl January 9, 2006, 6:21 am
Converting codepages to UTF8 March 30, 2006, 9:04 am
converting the contents of a scalar May 4, 2006, 2:43 pm
converting vba to perl without win32::ole September 8, 2006, 9:34 am
converting php md5 function to perl September 12, 2006, 4:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap