in reply to eliding number ranges

Not strictly (or even loosely) a point about perl, but about style. You said you wanted your output to be "like a book index." Some style manuals demand a behavior that your description of your desired output doesn't handle. The number of "significant digits" should never be less than two if both the page numbers have more than two digits. Example: 204, 207 should yield 204-07. (1, 17, however, should yield 1-17).

Hope this helps. (And yes, I actually have worked as a copyeditor.)

BCE
--Your punctuation skills are insufficient!