in reply to Re^2: How to write better code?
in thread How to write better code?

It's an interesting point. I almost put in a paragraph on this (saying that some people would suggest dropping the naming variables).

I tend to view naming vars almost a substitute for comments. They can be a way of better documenting your intent. I mused about that a bit here.

That said, there's also a lot to be said for brevity, and I like your code too :-).

If I'm honest, I suspect I'd have dispensed with the @components intermediate array, but written out the foreach. I think this is because I rarely think of assigning arrays to lists (and avoiding using a side-effect like $query{$x} = $y in a map clause is one of my reasons for using an explicit foreach). Maybe I should do that more often.

One hint is that I had a little trouble coming up with a good name for the intermediate array - always a good sign that it probably isn't necesary/desirable.