for (my $i = 3; $i >= 0; $i--) { close($handles[$i]); } #### close $handles[$_] for reverse 0..3;