in reply to Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)
Unless there's a CPAN module to handle this type of file, I'd consider building a finite state machine in Perl to handle the parsing. That way, you can read in a line, handle it -- starting or ending a state as necessary -- and move on.
One trick that might help is to keep a global or semi-global stack of the current position. If you're familiar with references, this would be a reference to the current position in the master hash. When you enter a new state, push a new hash reference on the stack. When you leave a state, pop the hash reference off. (Don't forget to store it in the master structure though.)
Does that make sense?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)
by idnopheq (Chaplain) on Oct 16, 2004 at 19:44 UTC | |
by SpanishInquisition (Pilgrim) on Oct 18, 2004 at 19:18 UTC |