ex: Name 'bob' 'sue' 'dave'. where Name is the key with three values separated by tabs. When values are separated by spaces then I get 'bob sue dave' as a single value.

So I'm stumped.

Me too. Are you saying that having "bob sue dave" as a single value in the combo box would be wrong? Or would it be right? If it's wrong, what sort of combo box is it, exactly, and in what way does it provide for offering/selecting multiple values relating to a given key string?

If having all the tab-delimited names concatenated in the one hash value would be right, you just need to change how you do the split:

... my($key, $value) = split(/\t/,$_,2); # might also need to do this: $value =~ s/\t/ /g; $$hash{$key} = $value; ...
The third arg in the split() call says "stop splitting when you get to the second item", which means, in effect, that everything after the first tab gets returned as one string, and no further splitting is done.

(And do heed the advice in the earlier reply: chomp lines inside the while loop before splitting, and skip empty lines within the loop, instead of assigning them to the hash -- i.e.   next unless $key and $value;


In reply to Re: creating hashes by graff
in thread creating hashes by philc

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.