It's not implied. It's irrelevant. Since /o controls the treatment of variables, and there are no variables, it can neither be implied to be present or absent. The question has no merit.
It's like saying "do I still get a free second helping of my entree with this coupon when all I'm having is dessert?" People turn their heads sideways when you say that. {grin}
Is it helpful? No. Is it harmful? No, except that including that switch on a regex without variables might make me question the rest of your Perl understanding in a code review.
| [reply] |
Is it helpful? No. Is it harmful? No, except that including that switch on a regex without variables might make me question the rest of your Perl understanding in a code review.
I'd say that it can be harmful. Given the dynamic nature of code, an /o on a RE could cause some hard-to-find bugs if the RE were modified to use a variable but the /o not removed. In fact, I'd advocate that /o on a RE without variables should illicit a warning when -w is in effect.
| [reply] |
Sounds like it's maybe harmful to the guy that comes along three years later to maintain the code. In my experience, something that's not needed and can cause confusion is better left out.
| [reply] |
Thank you for the explanation. Apparently, I was very confused.
--habit
| [reply] |
Funnily enough I came to the site to ask the same thing, and there was your question sitting at the top...
IMHO RS was a bit harsh on you (and, by inference, me) - for a general user (i.e. one who hasn't had to write their own regex parser), it is by no means obvious that a regex is only 'compiled' when it contains variables.
IMHO the problem is that 'compiled' is the wrong word in this context - compiling is something that is done to all code, not just variables. 'Expanded' might be a clearer term, but waddaiknow?
Tom Melly, tom@tomandlu.co.uk
| [reply] |
I wrote a longish thing about what exactly perl does with the /o flag at /o is dead, long live qr//!. Meryln's answer is about the same thing except succinct without all the the notes on the internals bits. | [reply] |