Monks i have hash in which i have 'Process' as key and 'Order' as value.
Key Value PR1 2 PR2 4 PR3 1 PR4 3
I want to do the processing of subroutines according to the precedence order given in the hash. For example in the above hash the 'PR3' should be executed first and 'PR1' second and so on. So in the following code, third subroutine should be processed first and first subroutine should be processed second and so on without changing the subroutine name. How to achieve this?
$input = &process1 ($input) $input = &process2 ($input) $input = &process3 ($input) $input = &process4 ($input)
I can achieve this by using the subroutine name as a key in the above hash and can call the subroutines after sorting as shown below. But i want the process name as shown above like '&process1'... and should not be changed to '&PR1'.... as i have tried below.
The way i tried one way (here i have changed subroutine name as per th +e key in the hash, which i don't want): for (sort keys %po) { $input = &$_ ($input); }
I think that is not the correct way. Is there any module or any other way to do this? I can also achieve by writing combination of four subroutines with different orders but i know that is not correct method.
The second way i tried but not correct (just i gave a try): for (keys %po) { $input = &process1 ($input) if (po{$_} == 1); $input = &process2 ($input) if (po{$_} == 2); $input = &process3 ($input) if (po{$_} == 3); $input = &process4 ($input) if (po{$_} == 4); }
Regards,
Anniyan
(CREATED in HELL by DEVIL to s|EVILS|GOOD|g in WORLD)
In reply to Process order by anniyan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |