please do NOT solve this entire thing for me...
Bravo!
There are several issues to consider.
First, is it possible that each of your substrings will contain commas themselves? From the looks of your list, the answer is no. Second, do you want punctuation (such as the trailing '?' question mark) to be included as part of that word?
The simplest solution will be to have a look at split, and use it with a comma followed by zero-or-more spaces as the delimiter.
Then, if you desire to strip away punctuation such as that trailing question mark, you can use a substitution operator (s///). See perlrequick andperlretut for details there. As a matter of fact, for simple character by character stripping of non-word characters, you can also use tr///. That's also covered in perlrequick if I'm not mistaken. Those are also covered in perlop and perlre, though those documents are more difficult reads.
But if you're dealing, instead, with a more complex dataset, where commas may be included within the text so long as the individual text element is itself quoted, then you had better look at Text::CSV where it's done right. That's an easy thing to goof up if you try to do it all with home-rolled regexps.
I hope this gets you going in the right direction without giving away the solution. The biggest step you can take in the right direction while learning Perl is learning to utilize the POD's (Plain Old Documentation that comes with Perl).
I'd like to see what you come up with, so if you get stuck, or once you complete it, post a followup to this thread so we can have a look at what you were able to put together. Then if you want, we can critique it for you to enhance your learning experience. :)
Dave
In reply to Re: Comma separated list into a hash
by davido
in thread Comma separated list into a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |