http://www.perlmonks.org?node_id=11144273


in reply to Re: Help with parsing a file (updated)
in thread Help with parsing a file

Thank you LanX, works great but I have realised that in my attempt to simplify the example I have missed a key info i.e. the data blocks are not separated by an empty line but by three lines of text with an empty line above and below. Also the blocks can be more than two.I have updated the question.

  • Comment on Re^2: Help with parsing a file (updated)

Replies are listed 'Best First'.
Re^3: Help with parsing a file (updated)
by tybalt89 (Monsignor) on May 29, 2022 at 22:05 UTC

    Words are not enough, please post a section of your real data that is "long enough" to show all the problems...

      I can post part of the real data file but it will be 2-3 pages long. Could I ask what should I use to add this update to the question i.e. the 'code' or the 'readmore' tag so that it displays properly and follows PerlMonk's best practise?

        Note that you don't need to actually post much data. Strip it down to show the salient variations. Any text that isn't important for identifying records or data items or parameters can be omitted or abbreviated as appropriate. Background like how the original file is generated may be helpful to give us some idea of how much variation there may be in elements of the format. The smaller you can make the data and still be clear about the actual file format the easier it will be to figure out how to parse it.

        If the sample we have already is representative of the actual data (exact naming format aside) we don't need large lumps of additional data. It is important that anything related to record breaks is accurately represented though.

        Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
        Best reply to yourself IMHO.

        Updates to posts which had already so many replies are confusing.

        Explain why and use readmore and code

          here some more accurate input data ...
          <readmore> <code> DATA </code> </readmore>

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

        update

        ) i.e. your root node

      I have provided part of the real data file as suggested.