|
From: John Bokma on 2 Nov 2005 21:30 Gunnar Hjalmarsson <noreply(a)gunnar.cc> wrote: > A better parallel IMO is that it's like complaining when someone calls > a function using '&' without knowing the implications of doing so. It > 'works' most of the time, but not always... Yup, I agree on that one. If I see &sub, I assume that the user requires the & there. Same with /s or /m. It confuses me if it's just there and adds line noise. -- John Small Perl scripts: http://johnbokma.com/perl/ Perl programmer available: http://castleamber.com/ I ploink googlegroups.com :-)
From: Tad McClellan on 2 Nov 2005 21:02 Dr.Ruud <rvtol+news(a)isolution.nl> wrote: > Anno Siegel schreef: > >> The changes by /x only affect the regex proper. The replacement part >> is still an ordinary double-quotish string. > > OK. I am still trying to think up why it was chosen to not affect the > replacement part. Because spaces are _supposed_ to matter when they are in a string. -- Tad McClellan SGML consulting tadmc(a)augustmail.com Perl programming Fort Worth, Texas
From: Stan R. on 2 Nov 2005 22:27 Tad McClellan wrote: > Dr.Ruud <rvtol+news(a)isolution.nl> wrote: >> Anno Siegel schreef: >> >>> The changes by /x only affect the regex proper. The replacement >>> part is still an ordinary double-quotish string. >> >> OK. I am still trying to think up why it was chosen to not affect the >> replacement part. > > > Because spaces are _supposed_ to matter when they are in a string. Tad, what I think he might be getting at is if there soem a possibility to have a modifier on a literal strings to allow cmments. I cna see how doign that might not make a lot of sense in many ways (its a string for cryin' out loud!), but I just thought I'd point out it seems his thinking is hinting in that general direction perhaps. -- Stan
From: Tad McClellan on 2 Nov 2005 21:51 Gunnar Hjalmarsson <noreply(a)gunnar.cc> wrote: > What's PBP? Peanut Butter Perl? :-) Or "Perl Best Practices": http://www.oreilly.com/catalog/perlbp/ -- Tad McClellan SGML consulting tadmc(a)augustmail.com Perl programming Fort Worth, Texas
From: Anno Siegel on 3 Nov 2005 04:46
Abigail <abigail(a)abigail.nl> wrote in comp.lang.perl.misc: > Gunnar Hjalmarsson (noreply(a)gunnar.cc) wrote on MMMMCDXLVI September > MCMXCIII in <URL:news:3ss54cFpe3koU1(a)individual.net>: > ** 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. |