in reply to Process order

If all priorities are unique, the sorting can be done very simply with reverse:
#!/usr/bin/perl -w use strict; my %input = ( PR1 => 2, PR2 => 4, PR3 => 1, PR4 => 3, ); my %by_priority = reverse %input; foreach (sort keys %by_priority) { print $by_priority{$_}, "\n"; }
Which gives:
$ ./foo.pl PR3 PR1 PR4 PR2
After sorting, I would use a hash of code references (as in davorg's reply) to execute the actual processes.