You can sort the keys by value,

my @sorted = sort {$po{$a} <=> $po{$b}} keys %po;
You would do better associating a name to coderef through a hash, an arrangement usually called a dispatch table. What you're trying is calling through symbolic references.

(Added) With your calling pattern of calling on and modifying $input, you might consider writing your subs to modify their argument.

my %process = ( PR1 => sub { $_[0] = process1($_[0]) }, PR2 => sub { $_[0] = process2($_[0]) }, # . . . ); my %po = ( PR1 => 4, PR2 => 2, PR3 => 1, PR4 => 3, PR5 => 5, ); for (sort {$po{$a} <=> $po{$b}} keys %po) { $process{$_}($input); }
It would be best if you made sure all the keys of %po existed in $process. How are you deciding priority? That could have a huge influence on how you actually do this.

After Compline,
Zaxo


In reply to Re: Process order by Zaxo
in thread Process order by anniyan

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.