![]() |
|
No such thing as a small change | |
PerlMonks |
Re: How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?by LighthouseJ (Sexton) |
on Dec 14, 2007 at 16:43 UTC ( [id://657078]=note: print w/replies, xml ) | Need Help?? |
I'm the king of writing C-ish Perl at least on the initial attempts. I know assembly code so I understand how much of a luxury C is so I'm eager to use it. When I get to use Perl, my initial edits reek of C-style editing. However, as I refine the code, I shed the C-code and get to use pure Perl. I have noticed that to shed the C-code, you pretty much have to exclusively use only the Perl functions. Take the obfuscations that people write, they are incarnations of pure Perl facilities, usually in obfuscated forms. Sure, I could write a Perl program: Not only is that not obfuscated but it's also very C-like. The only difference is identifying variables with dollar signs, and using print instead of printf (for it's closest-named C counterpart). Now if I was going to shake off the C-style, I'd look for Perl-specific ways of streamlining this program. Eventually, after several iterations (because I don't claim to be a super perl programmer, just aware enough to do damage), I might be satisfied on this: Not counting the interpreter line and use strict, see how I reduce everything down to only the things I need? I need to print something, state the format including where to put the variable, then repeat. That's all, no variable declarations, traditional loop structures, etc... When you use Perl-specific mechanisms, that is only the minimum need to do the job, there won't be any use for traditional C-style coding behavior.
"The three principal virtues of a programmer are Laziness, Impatience, and Hubris. See the Camel Book for why." -- `man perl`
In Section
Meditations
|
|