Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
If changing the 5 to 4 yields '0.0', then I think it's actually yielding ' 0.0' (that's space-zero-dot-zero), which means your offset of 118 might be wrong.

The reason your code is failing, in general, is because your logic is faulty. You think your code is saying "print the contents of the array if there's a line with '0.00' at offset 118", but your code is NOT saying that.

Your code is saying:

for each line in between 'NAME' and 'ADJ TO TOTALS:', do this { add this line to the @data array now go through each element of the @data array, and do this { # <-- + WHY?! if this line has 1235114182 in it, do this { put this line at the end of $lines if $lines has '0.00' at offset 118, do this { print the @data array } empty the @data array, $lines, etc. } } }
Your code is faulty because it won't print any line that DOESN'T have '0.00' in it.

I suggest you try my sample solution and plug in the values for $target, $pos, 'START', and 'END'.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
Nos autem praedicamus Christum crucifixum (1 Cor. 1:23) - The Cross Reference (My Blog)

In reply to Re^5: Regex Not Grabbing Everything by japhy
in thread Regex Not Grabbing Everything by JonDepp

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 learning in the Monastery: (6)
As of 2024-04-23 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found