my $x='ok'; # scads of code my $x=300; while ($x--) { do_something_with($x); } # scads of code... print "$final" if ($x eq 'ok'); #kaboom