Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: /g option not making s// find all matches

by raygun (Scribe)
on Jun 01, 2018 at 04:11 UTC ( [id://1215595]=note: print w/replies, xml ) Need Help??


in reply to Re^2: /g option not making s// find all matches
in thread /g option not making s// find all matches

Simple, clear, one-step fixup
Yes, and absolutely the solution I would use if my real-life problem matched this simplified example of looping through an array or input stream. My code is doing the opposite: siccing an array of regex substitutions on a single string. Thus each modification has to be containable in an s///. (I can handle special cases outside this array, but minimizing special cases is a goal.)
Please don't use # as a delimiter for regex expressions
Yeah, I get that it indicates a comment, but for simple, inline expressions such as that one (a whole six characters after the tr), I like it for how it visually stands out better than most characters within a typical regular expression, making it easy to find the boundaries of each element. In code I write, all comments are set off with plenty of whitespace, so the eye won't be tricked into thinking a comment is lurking in the middle of what otherwise looks like a line of code. ("@" also stands out in many terminal fonts, but that would be true perversity.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1215595]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-18 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found