Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Good practice with $_ scope?by davies (Prior) |
on Jun 12, 2016 at 14:53 UTC ( [id://1165423]=note: print w/replies, xml ) | Need Help?? |
If you don't have standards telling you when to do these things (if, like me, you are coding for your own fun & education or if you are a one man shop), then you should do what fits your brain. If you find it clearer to localise $_ every time, go ahead. My attitude is that, if there is the slightest possibility of confusion, I assign to a named variable rather than use $_. So part of your code might, in my idiom, become:
But if you are working alongside anyone else, ask them what they do or, if they are unfamiliar with the construct, what they find clearest. They may have to maintain your code or you theirs. In either case, it would be better if you had a common style and understood each other's idioms. Regards, John Davies
In Section
Seekers of Perl Wisdom
|
|