Beefy Boxes and Bandwidth Generously Provided by pair Networks
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:

  • . matches any single character other than \n
  • ^ matches the start of the string
  • $ matches the end of the string

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
in thread Pattern Matching by davidas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2024-04-25 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found