The thread to date sounds like you are not posting enough information, and that you've scrubbed your example too much to effectively debug. Please read
How do I post a question effectively?, in particular, make sure that you post self-contained code that shows the problem. What happens in the subroutine? Nothing that's been posted should be resetting the
getgrent iterator, though if you invoke it in your subroutine, that could mess you up. Note that the one-liner
perl -E 'sub func {"@_"} while (($name) = getgrent){if ($name =~ /^som
+etext_(\w+)/){func($name,$1);say $name}}';
runs just as I would expect, with no infinite loop.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.