|
|
| Don't ask to ask, just ask | |
| PerlMonks |
[Resolved] Parse a file into a hashby kazak (Beadle) |
| on Apr 05, 2012 at 09:07 UTC ( #963617=perlquestion: print w/ replies, xml ) | Need Help?? |
|
kazak has asked for the
wisdom of the Perl Monks concerning the following question:
Hi 2 everyone. I need to parse some file into a hash, but the thing is that this file is a list, similar to this:
key1 value1 key2 value2 value3 vasue4 key3 value5 key4 value6 value7 key5 key6 As you can see quantity of possible keys and posiible values isn't matching. And on top of this I need following:-If the key for a certain string doesn't exist previous value must be used I mean:key1 value1 key2 value2 key2 value3 key2 vasue4 If the value for certain string doesn't exist, it should be repalced with empty value: key5 <empty> key6 <empty> So the resulting hash should be:key1 value1 key2 value2 key2 value3 key2 vasue4 key3 value5 key4 value6 key4 value7 key5 empty key6 empty I hope someone can help me with this.Thanks in advance, kazak.
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||