Hmm, you're assuming wrong. That *is* my actual code :)

I chose this way of doing it (as far as I remember) because it was easier to read a list of method names/patterns from an external (plugin) module and add them to my Hash at the time. I'm not quite sure how that would work using anonymous subroutines, and if its not more dangerous creating them with eval..
(Maybe I should post how I do that at the moment..)

If someone types 'logic' then it does nothing at all.. thats why I compare the length of the command to $data, *and* then compare the pattern. As the pattern has 'log<space>' in it, it won't match.
Using compiled regexs sounds like an idea, if they're faster, I've not used qr// yet, so I'll have to look that up.
Also grouping the types of commands was something I'd thought of, but didn't get around to trying out yet :)

(P::RD is a tad too slow for mud triggers.. :)
C.


In reply to Re: Re: Complex dispatch table by castaway
in thread Complex dispatch table by castaway

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.