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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Why do you suppose this is happening? Have you taken any steps besides posting to figure out why the solution isn't working for you?

When debugging it's often helpful to check the state of the program's logic at one or more points. An easy way to do this is with "print" statements that give you clues as to where you are within the program's control flow.

For example, if you added a print "Record: $.\n"; statement as the first line of the block of your while() loop you would see each time the loop iterates over a new record. And if you added print "New match: $number\n"; as the first line of the if() block, you would see each time a new number is matched and captured into $number. After running the script with those two debugging aids you would probably see that the file is being read in as one big record, rather than as multiple records.

That seems impossible if your input data matches the data you showed us, and if you're executing the code you say you are. Either you've got $/ = ''; in your code, or you have data that isn't separated by two newlines like it appears in your post. At least those are my best guesses without seeing exact cut&pastes of the first few records of your data, and of the script exactly as it's being run.

For what it's worth, I copied and pasted the exact data you posted here and used that as the sample run for my solution. I also copied and pasted the exact data that you posted in your followup, and it also produced the correct results.

Is it possible that you're re-typing the data rather than copy/pasting it, and that the blank line between records actually contains some space characters that we can't see, and that you didn't paste into your example data?

By the way: This isn't contributing to your problem, but it is a darn good idea anyway: Put use autodie; right after the use warnings; line at the top of your script. That will alert you if a file fails to open (among other things).


In reply to Re^3: Modify a txt file by davido
in thread Modify a txt file by la

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (7)
    As of 2015-11-25 07:20 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (672 votes), past polls