punkish has asked for the wisdom of the Perl Monks concerning the following question:
I have an arbitrary string like so
I want to convert this intoABCD----[this] fgab [that] BFTE-- [other]
%hash = ( ABCD => 'this', fgab => 'that', BFTE => 'other', );
I say "arbitrary" because there are many such strings, and they are all different. The only pattern is that the characters within the square brackets are the values, and the characters to the left of the square brackes are the corresponding keys, except for the silly dashes or spaces in between the key and the value. In other words,
would beAB CD EF---- [foo]
To make life more interesting, the number of keys and values varies from string to string.'AB CD EF' => 'foo',
muchas gracias por adelantado.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: converting an arbitrary string into a hash based on a pattern
by holli (Abbot) on Mar 04, 2005 at 04:23 UTC | |
by Anonymous Monk on Mar 04, 2005 at 04:55 UTC | |
by lidden (Curate) on Mar 04, 2005 at 05:00 UTC | |
|
Re: converting an arbitrary string into a hash based on a pattern
by gopalr (Priest) on Mar 04, 2005 at 04:43 UTC | |
|
Re: converting an arbitrary string into a hash based on a pattern
by punkish (Priest) on Mar 04, 2005 at 05:05 UTC | |
by holli (Abbot) on Mar 04, 2005 at 06:03 UTC | |
|
Re: converting an arbitrary string into a hash based on a pattern
by ssk (Initiate) on Mar 04, 2005 at 09:54 UTC | |
by holli (Abbot) on Mar 04, 2005 at 10:13 UTC |