A dispatch table of the funcs:

#! perl -slw use strict; my %dispatch = ( A => sub{ map{ $_ +1 } @_ }, B => sub{ map{ $_ *2 } @_ }, C => sub{ map{ $_**2 } @_ }, D => sub{ map{ $_ +3 } @_ }, E => sub{ map{ $_ *5 } @_ }, ); my $func_com = $ARGV[ 0 ] || 'ABC'; my @some_val = 1 .. 10; @some_val = ( $dispatch{ $_ } || sub{ @_ } )->( @some_val ) for split '', $func_com; print "$func_com: [ @some_val ]"; __END__ c:\test>junk6 ABC: [ 16 36 64 100 144 196 256 324 400 484 ] c:\test>junk6 A A: [ 2 3 4 5 6 7 8 9 10 11 ] c:\test>junk6 B B: [ 2 4 6 8 10 12 14 16 18 20 ] c:\test>junk6 AB AB: [ 4 6 8 10 12 14 16 18 20 22 ] c:\test>junk6 C C: [ 1 4 9 16 25 36 49 64 81 100 ] c:\test>junk6 AC AC: [ 4 9 16 25 36 49 64 81 100 121 ] c:\test>junk6 ABCDE ABCDE: [ 95 195 335 515 735 995 1295 1635 2015 2435 ] c:\test>junk6 F F: [ 1 2 3 4 5 6 7 8 9 10 ] c:\test>junk6 FA FA: [ 2 3 4 5 6 7 8 9 10 11 ]

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Howto avoid large hard-coded else-if function calls by BrowserUk
in thread Howto avoid large hard-coded else-if function calls by neversaint

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.