in reply to Re^3: Useless use of private variable in void context
in thread Useless use of private variable in void context
Welcome to the Monastery.
It depends how fluent you wish to be - how much you wish to sound like a "native".
The c-style loop you used is fine, it gets the job done, but it is C written in perl. It would be similar to my trying to speak Spanish to a native speaker. I could convey meaning (hopefully the correct meaning), but would in no way be considered fluent. In some cases (transferring English idioms into Spanish, for example), I would only be understood by someone that could follow how I got to the translation I used.
If I were to immerse myself in the language, I would hope that I would become more fluent, and stop trying to use English idioms in was that do not make sense. I might even start using Spanish idioms effectively.
It comes down to communicating ideas. As you start to use the idioms and base your communication on the language at hand, you can be more effective at transferring your ideas to others.
Many times when one comes into Perl from another language, that person will write their other language in Perl. It isn't wrong to use the c-style loop, there are just more perlish ways to do it.
I am also not saying that you should never use the c-style loop. There are times when it would be more appropriate than the for/foreach loop above.
--MidLifeXis
|
|---|