Actually, I disagree. The provided code is actually visually very helpful, as it leads (mind you, leads, not misleads) the reader to think that bar() makes sense in the context of foo().
in reply to Re: a sub within a sub -- revisiting
in thread a sub within a sub -- revisiting
From OOP we know that Perl doesn't protect methods and variables. Perl would much rather that you didn't come into its home uninvited than put locks on its doors. The reader of the code should simply not call bar() from outside foo().
That said, the suggestion to convert bar() into an anonymous sub is a good one. That makes things even clearer.
when small people start casting long shadows, it is time to go to bed