rvf has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing multiple values in a singe line
by extremely (Priest) on Apr 05, 2001 at 23:40 UTC | |
|
Re: Parsing multiple values in a singe line
by thabenksta (Pilgrim) on Apr 05, 2001 at 22:22 UTC | |
|
Re: Parsing multiple values in a singe line
by suaveant (Parson) on Apr 05, 2001 at 22:38 UTC | |
|
Re: Parsing multiple values in a singe line
by Anonymous Monk on Apr 05, 2001 at 22:17 UTC | |
by tye (Sage) on Apr 06, 2001 at 00:06 UTC |