in reply to Re^2: scalar out of a loop
in thread scalar out of a loop

My answer is the same, except that you'd replace my $comment by my $done.

Or maybe I misunderstood your question still.