Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
One way to make sense of your former employee's code is to use the /x modifier on the regex, which lets you throw in whitespace for formatting without screwing up semantics (except that you'll need to encode whitespace as \s -- thanks, grinder). With this, the regex will look something like
m/ .* ( [\$#\%>~] | \@\w~\$ | \\ \[ \\ e \[ 0m \\ \] \s \[ 0m ) \s? /x
which basically says
  • skip past as many characters as possible, then
  • match one of three things
    • a single character that is one of $ # % > ~
    • a four character string beginning with @, following by a single "word" character, followed by ~ and $
    • the string "\[\e[0m\] [0m"
  • allow for an optional trailing space

With the "one of these three things" going into the Perl variable $1. In short, this regular expression isn't matching what you think its supposed to be matching. The third alternative looks like it's inteded to capture an escape sequence of some sort.

So yeah, it looks pretty messy.


In reply to Re: This looks like someone sneezed and hit the keyboard by dws
in thread This looks like someone sneezed and hit the keyboard by Anonymous Monk

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 cooling their heels in the Monastery: (5)
As of 2024-06-14 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.