ralfthewise has asked for the wisdom of the Perl Monks concerning the following question:
I want to do the following from a text file with entries delimited by :'s
1. read a line from a text file
2. first word(s) becomes the hash name
3. next 4 words go into key,value pairs
4. repeat to EOF
ex:
name: bob: jane: joe: sue:
name2: john: me: oh: my:
So, I want a hash called name. With key,value pairs to look something like first,bob....second,jane and so on. And a second hash called name2. With key,value pairs to be first, john....second,me...etc.
I've been playing with regexes and splits with varying degrees of a total lack of success.
John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parsing text file into a hash?
by davorg (Chancellor) on Jun 15, 2001 at 20:17 UTC | |
|
(Ovid - a slice of hash, anyone?) Re: parsing text file into a hash?
by Ovid (Cardinal) on Jun 15, 2001 at 23:08 UTC | |
|
Re: parsing text file into a hash?
by runrig (Abbot) on Jun 15, 2001 at 20:14 UTC | |
by Everlasting God (Beadle) on Jun 15, 2001 at 22:22 UTC | |
by ralfthewise (Sexton) on Jun 15, 2001 at 22:53 UTC | |
by runrig (Abbot) on Jun 15, 2001 at 23:46 UTC |