foreach $key(@X) { &subA($key); #returns the result of check, if yes then #assign new values else ignore &subB; #subA returns an array of elements whose values #need to be reassigned. subB then assigns value }