You can sort the keys by value,
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.my @sorted = sort {$po{$a} <=> $po{$b}} keys %po;
(Added) With your calling pattern of calling on and modifying $input, you might consider writing your subs to modify their argument.
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.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); }
After Compline,
Zaxo
In reply to Re: Process order
by Zaxo
in thread Process order
by anniyan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |