This is my first question to the monks so apologies ahead of time if I break any cardinal rules.

My problem is that I'm trying to parse several files of an odd (to me at least) format. The file begins with an ASCII header which is then followed by binary data (a FITS image to be exact). These values, when viewed in an 80 column display, appear to be on multiple lines, while in fact they are one very long line.

Here is a trimmed down example of the headers(with artificial newlines for readability)...

SIMPLE = T / file does conform to FITS standard BZERO = 32768 / zero point LOISVERS= 'LOIS V1.0.1' / LOIS Version DETECTOR= 'NAVY TI 800x800' / detector name INSTRUM = 'Lowell 10 Filter Wheel' / instrument name FILTNAME= 'V ' / Filter Name END [...lots of whitespace...] [binary data]

Keep in mind that each line you see above is part of a single string that pads each statement with 80 chars to create the illusion of seperate lines. What I need to do is extract certain FOO      = bar values, while ignoring others and tossing out the binary data after END. Some values are in quotes while some are not. I also can't rely on a static length of chars for the values (as INSTRUM demonstrates). I'm somewhat stumped as to what sort of regexp (or something else?) that I need to approach this with - any ideas?


In reply to Parsing multiple values in a singe line by rvf

Title:
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, details, 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, summary, 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.