That makes sense, thought the syntax of creating your hash must get a bit messy unusual if you have large and/or many subs. Only a bit though.

I was just thinking about how you would handle modularising the functionality, in terms of the source code rather than semantically?

I probably haven't thought this through properly yet, but to try and explain what I mean, say your writing an editor. The dispatch table is used to invoke actions depending upon user input. The user input can take the form of keystrokes, mouse gestures, CLI comands and possibly menus. Ignoring for the moment any problems that might arise from storing/translating keystroke or mouse gesture info into a hash key. It makes a certain amount of sense to segregate the functionality along those lines into seperate modules, if only for ease of editing. I realise that the segregation would more likely be on the basis of different criteria (eg. edit action on current file, configuration action on current file, global configuration action etc.)

The point is, once you have sub code in different source files, how would you go about building this into a dispatch hash for use in the main input queue processing loop?

Add to this the requirement to allow the remapping of the keyboard commands and the desire for the ability to define keystroke/menu commands to user defined 'macros' (I use the term loosely) and I having trouble envisioning how to build and maintain the hash table.

This is actually quite close to something I'm working on right now, hence my interest.


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.


In reply to Re: Re^7: Naming Subs by BrowserUk
in thread Naming Subs by eoin

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.