in reply to scalar out of a loop

Maybe you don't want to export a variable out of the loop, but set an existing variable to a different value?

my $comment= '- no comment found -'; foreach my $hash_ref2 (@result2) { $comment = $hash_ref2->{'comment'}; if ($comment =~ /^this is an automatic +comment/) { last; } } print $comment;

Replies are listed 'Best First'.
Re^2: scalar out of a loop
by mitchreward (Acolyte) on Jul 21, 2014 at 14:24 UTC
    No, but you're right that was not complete. I've updated my post.

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

      Or maybe I misunderstood your question still.