in reply to Oft encountered regex problem
In any case - what you are going to want to do is figure out how to split your data into key and value pieces. You have three things to split on - ": ", " is ", and " at". You are going to want to limit the split to just two pieces since the rest of the string may duplicate the delimiter.
This has some problems. You are assuming you will not encounter the same key name twice in the same data file - that would overwrite the first one. You are also not building the hash with a single regex like you asked, but iterating over the data splitting each line into two pieces.my ($key, $val) = split /(: | is | and )/ , $_, 2; $info{$key} = $val;
It seems to me that if you were processing a lot of these types of records at once you would want to use an AoH.
If you can give a little bit more context of what you are trying to accomplish, I would be glad to help further.
Cheers - L~R
|
|---|