$ perl -E ' use strict; use warnings; my $i; for $i (1,2,3) { say $i; } say $i // "undefined"; ' 1 2 3 undefined