Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

The easiest way to get the part of the data before the string was found is to capture all of it.

Another approach is the one [id://Trix606] suggested... but be careful with it (as perlvar says): it impose a penalty on every regular expression... which slows down each match. Which is a bad idea.

Yet another approach is mentioned in the perlretut pod.

Some comments on this code. (Maybe relevant, maybe not.)

First, posting the code you are actually using might proof to be easier... and will result in better help.
(I say this because you have a syntax error in your code... (a missing ; after the print statement). This makes me guess that you didn't post the actual code)

Second, What if @dependantFiles contains a regex charachters? Do you want them to be interpreted or not? If not then you should look at the quotemeta function and/or \Q and \E in one of the perlre PODS (perlreref might be a good starting place).

Speaking about the regex: there is no need for the regex to be global. So drop the /g.

Another good idea is to use a lexical loop variable... it will make your live easier...

Doing next; at the end of the loop is pretty useless... (but it might make more sense in your actual code... (as in, the next is in an if-statement, and there is some other code behind it))


In reply to Re: regex expression help by Animator
in thread regex expression help by JFarr

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 surveying the Monastery: (2)
As of 2024-04-25 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found