This doesn't look like a dispatch table to me. If you're reading in a bunch of sub names from an external source, and calling them, order may matter. Hashes don't preserve that. "But I'm just suggesting using the table to convert from string to code ref! You can use the order of strings to control the order!" True, but why produce another hash when the symbol table (another hash) already exists, with ways to query it?
$ perl -le 'sub foo { }; print \&foo;print __PACKAGE__->can("foo")'
CODE(0xf81930)
CODE(0xf81930)
No non-strict code. And when I add new functions, no need to remember to update the symbol table - perl does that automatically.
Don't get me wrong. I like dispatch tables. I use them. A lot. This just doesn't seem like a use for them to me, mostly because it seems like the OP is trying to loop through them.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|