in reply to Process order
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Process order
by anniyan (Monk) on Jun 09, 2006 at 11:27 UTC | |
by ikegami (Patriarch) on Jun 09, 2006 at 14:39 UTC |