kazak has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse a file into a hash
by moritz (Cardinal) on Apr 05, 2012 at 09:13 UTC | |
|
Re: Parse a file into a hash
by raybies (Chaplain) on Apr 05, 2012 at 13:01 UTC | |
by kazak (Beadle) on Apr 05, 2012 at 20:21 UTC | |
by aaron_baugher (Curate) on Apr 05, 2012 at 22:19 UTC | |
by kazak (Beadle) on Apr 06, 2012 at 14:50 UTC | |
by mendeepak (Scribe) on Apr 07, 2012 at 05:55 UTC | |
|