Re: s///x



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.
.



Relevant Pages

  • Re: More deception from the left and the useless MSM.
    ... they cut from the bottom. ... Newspaper reporters are ... You must mean the "overall meaning" of leaving all the felony charges ...
    (rec.boats)
  • Re: Reading a string of unknown size
    ... In fact, the English word "redundant" means exactly that, in the ... Those many people are just as wrong as Paul, ... But I will point out that, even as a new meaning for a word becomes ...
    (comp.lang.c)
  • Re: We shall not, we shall not be dressed!
    ... It's redundant in the sense that it does not change the meaning of the ... I accept it is badly phrased (as is rather a lot of law unfortunately, ... examples of the types of discrimination that the authors had in mind, ...
    (uk.rec.naturist)
  • Re: [opensuse] undeleting files [OT]
    ... Proper mail clients (meaning those with topic thread support (meaning ... everything except Outlook / Outlook Express)) make this explicit to ... Manually deleting all the redundant copies ... It has for years been the practice on this list to reply _only_ to the ...
    (SuSE)
  • Re: Anglo-Saxon Naming Traditions
    ... name's meaning, only a certain class would be entitled to a certain ... better approach may be look at relative proportions of names held by ... pre-Viking period -- though perhaps Saints' Lives might be utilised? ... Certainly gathering only the very top and bottom seems ...
    (soc.history.medieval)