Re: s///x
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 3 Nov 2005 09:46:13 GMT
Abigail <abigail@xxxxxxxxxx> wrote in comp.lang.perl.misc:
> Gunnar Hjalmarsson (noreply@xxxxxxxxx) wrote on MMMMCDXLVI September
> MCMXCIII in <URL:news:3ss54cFpe3koU1@xxxxxxxxxxxxxx>:
> ** Dr.Ruud wrote:
> ** > Gunnar Hjalmarsson schreef:
> ** >>Note that the /s modifier is redundant (see "perldoc perlre").
> ** >
> ** > I don't consider the /s modifier redundant. It was not needed in my
> ** > example, so maybe you meant "redundant here"?
> **
> ** Okay, redundant (or extraneous...) here. I mentioned it because people
> ** misunderstand the meaning of it all the time, and I believe one reason
> ** for that is that "perldoc perlre" - unlike e.g. "perldoc perlop" - is
> ** the only place in the docs (to my knowledge) where its meaning is
> ** properly explained.
>
>
> Damian makes a good argument in PBP to always use /s and /m.
The recommendation is to use /xms on all regular expressions, whether
the modifiers make a difference or not. It is not an invitation to add
combinations of /x, /m and /s at random.
> I don't think it's worth raising your finger if someone uses /s or /m
> on a regex where it doesn't matter. It's like complaining someone uses
> 'use warnings' on a piece of code where it didn't matter.
....or like using "sort keys ..." where "keys ..." would have done?
It really depends on what the rest of the code is like -- context. If
the general quality of the code is good, an redundant /m is, of course,
no big deal. In code that is clearly written by a beginner, it is a
sign of insecurity and/or cargo culting and ought to be pointed out.
As a reader of a piece of code, it is important to develop a feeling
for the authors competence -- how far can you trust the code. Redundant
constructs are an important indicator *against* the authors competence.
That's why it is generally a good idea to avoid them.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- Re: s///x
- From: Dr.Ruud
- Re: s///x
- References:
- Prev by Date: Re: m//ms (was Re: s///x)
- Next by Date: Re: s///x
- Previous by thread: Re: m//ms
- Next by thread: Re: s///x
- Index(es):
Relevant Pages
|