good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Indisputable, you say? Perhaps not. By avoiding use re I never have to worry about what . ^ $ do because they mean precisely what they have done for the last couple of decades, viz:
Could not be simpler. If anyone should need to use /m or /s then they can tack that on to the regex as a modifier and anyone reading the code sees that it's clear that in this one case things might be different. (I've disregarded /x here as nobody ever needs that - it's just for syntactic clarity) However, if someone has done as you espouse then I might be entirely unaware of it because this declaration might occur nowhere near the regex I would currently be examining. A module with several thousand lines is (alas) not uncommon and a use re declaration on line 1000 is no use to me if I'm looking at line 4000 trying to work out why the hell the regex is misbehaving. It is my considered opinion therefore that use re /flags is likley to cause more problems than it solves with the notable exception of its use in a strictly limited lexical scope of a handful of lines or (at worst) a single self-contained subroutine. It's unlikely that I would ever use it even in that scenario, except perhaps to negate what some less charitable programmer might have set up more globally. Other opinions are available, of course, and there are no doubt various subjective reasons to choose one approach or the other. But your assertion that it is indisputable is unfounded. In reply to Re^6: Pattern Matching
by hippo
|
|