Remember "first element," "second element," etc are meaningless for hashes. You could use an array, which would maintain order, with the array indexed by id number (and having lots of elements that are undefined, potentially having several thousand empty array elements). Since your list is fairly small -- only 105-1 elements -- this is not likely to be too onerous. You could then store the (sparse) array as {id,name} pairs, with a convenient separator. You could, similarly, store them in a hash indexed by id number (just give yourself an id number of '0000' and Caroline one of '0001', so sort(keys(%hash)) returns these two names first and second).

Revising your specifications somewhat (and making them more general), what you seem to require is to generate a list of names and an associated unique numerical identifier, and then be able to print the list with one or more specific names omitted. For this, a tied hash is probably the optimum solution, as it will permit you to keep a permanent, and easily maintained, list.


Information about American English usage here and here. Floating point issues? Please read this before posting. — emc


In reply to Re^5: Print hash except first value by swampyankee
in thread Print hash except first value by joec_

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.