I still don't quite understand why 'four' is being repeated. When I delete {2} the key and value of 3/three should be removed and a print with the result:
0 ==== zero
1 ==== one
2 ==== three
3 ==== four
I wrote a note above that goes over why I'm not using an array. This hash in reality isn't being used, this is a test script I setup to see if it would work. I'm actually tying this hash to SDBM and sorting by numbered keys has never been a problem for me using
for (grep defined($_), (sort { $a <=> $b } keys %code).
The reason I need to rebuild the hash is because in the admin panel, when they remove a key/value, the user is returned to a menu with back and foward buttons that lets them scroll the data. For the forward button, I increment the key value by one, and the opposite for the back button. BUT, if we have keys 1, 2, 3, 4, 5 and they remove 3, the navigation buttons crash between two and four because it loads 3 which doesn't exist.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.