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); }