|Perl Monk, Perl Meditation|
How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?by amarquis (Curate)
|on Dec 13, 2007 at 14:22 UTC||Need Help??|
Dial your perldoc to perlsyn:
When I scanned the above yesterday, I realized that there is a lot of C in my Perl. I, without a doubt, would have rolled the C loop to solve that problem. I don't want to focus too much on that example, though, it's just the catalyst that made me start thinking about this.
It's all over my code, I'll roll a C-style loop where a map would fit better, I'll go for the C solution rather than use better suited Perl idioms. Sometimes I'll notice this after the fact and write it better, sometimes I won't. But what really worries me is that I'm not really getting better at it over time. Sure, I know more about Perl and have a handle on more advanced features now, but I'm not really writing much better code than I did 5 years ago. Maybe it's because Perl isn't my main breadwinner, maybe I'm just stubborn.
Can you teach an old dog new tricks? Or rather, can you point me towards any kind of resource that would help? Or talk about your own experiences, or anything else you think would be useful.
For reference, the things that have made me "okay" at writing Perl so far are:
And that's that. Oh, also I put this in Meditations rather than Seekers because it seemed like the place for this kind of open-ended discussion-ish question, but I can axe it and move it if people want.
Edit: (Dec 14, 2007 at 15:40ish UTC): Thank you all for so much advice in such a short time. I think my plan going forward would be to:
As to why I want to change, I currently write "okay" code with "okay" maintainability when working with Perl. I suppose I'm sort of annoyed that tool I'm happiest with is the one I produce the worst product with.