Hello fellow monks!

I have a complicated parsing to do and got a little stuck here.
I need to parse lines of the following shape:
allow:test1,"@test 2 " deny:test3,test4 password:"123 456"
and return the hash:
$hash = ( allow => [test1, "@test 2 "], deny => [test3, test4], password => "123 456", );
by the following rules:
1. if after the colon theres a list of comma separated arguments, retrun an array reference as the hash value.
2. if after the colon theres a single argument, return a scalar as the hash value. 3. strings in double quotes are of course count for a single argument.

I had a problem to split by space since I can have a space inside an argument in double qoutes, and spaces can appear in eny place in the argument (an argument can start/end with a space, e.g.: " test 1 2 ").
any help will be appriciated.

Hotshot

In reply to Parsing issue by hotshot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.