at a minimum, you should head jdporter's suggestions in response to the snippet you already posted. particularly since now you have all those chr calls inside a function body, so using the same set twice will redo all the computation.

Personally: I don't like duplicating data in a new format, you never know when the "authoritative" copy might change. i much prefer to have a tool to translate the data from the authoritative format to the format i want.

In this case, instead of a module with a bunch of hardcoded data structures -- how about an XML::Entities modules that knows how to parse the raw .ent files to generate the data structures? this would have the added benefit of working with all the various known entity sets and not just the one set you are currently interested in (not to mention, any custom entity sets someone else might make in the future)

That module could be used by the Makefile.PL of other modules (named things like XML::Entity::ISO8879) to automaticly download the .ent files the perl data structures to write as source code for fast reuse. (or at the very least, you could use a module like i describe at build time to generate modules like the one you've already made easily -- but other people could use it too.)


In reply to Re: RFC: XML::Entities by hossman
in thread RFC: XML::Entities by Sixtease

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.