in reply to Re^4: Print hash except first value
in thread Print hash except first value
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.
|
|---|