use strict; use warnings; my $x = undef; for( my $i = 1; $i < 5; $i++ ) { $x = $i; } print $x;