in reply to while loop break when sub call

Update your post using "code" tags around your Perl code: Writeup Formatting Tips

Your code does not compile for me. I get this error:

Illegal declaration of anonymous subroutine at ...

and with diagnostics:

Illegal declaration of anonymous subroutine at ... (#2) (F) When using the sub keyword to construct an anonymous subroutin +e, you must always specify a block of code. See perlsub.

There are other errors if you use strict.