As an addition, I found that the combination of "for" and if / elsif / else is good if you have code with a given / when / default that needs to be updated quickly. Just replace given with for and replace the when if cascade of if and elsif and replace default with else . This allows all of your tests to continue to use $_ implicitly, requiring less rewriting. (But keep in mind that other special intelligence matching features will no longer work.)
This is only for rewriting code that already uses the given / when. To write new code, @hobbs has the correct answer.
source share