-w or use warnings: with perl5.0, I prefer -w, with perl >= 5.6 I use warnings because it is not global. But for production code, i remove -w or use warnings with a comment because I don't want an inocent user be confronted with strange "error messages" they don't understand.
I prefer use constant CONSTANT => ...; because it makes clear that I want to use a constant and not a sub (although internally it all is about the same).
my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?
I use both, but prefer the first solution, because then I've got an entry in a subroutine at the very beginning, which may keep the code a bit more readable. But if you don't know how many parameters are coming, I sometimes use shift in a loop (with commenting a lot why to do so).
In bigger codes, I prefer using print as a function (print(...)), but I don't know why. One reason may be that with a good syntax highlighning editor, you can easier find matching parantheses...
glob '*' or <*>: since I have to work a lot with perl5.005_03, I prefer using the module File::DosGlob. With perl >= 5.6, I prefer glob
readline *FOO or <FOO>?: I always use <FOO>, because in my eyes, it is more idiomatic. But for a beginner, readline might be easier to understand in an existing code
foreach vs. while each: It just depends on what I need. If I need some way of sorting, I have to use foreach. If not, then I nearly always use each, because with bigger datastructures, it might be faster, and $key and $value are imho better namens than $key and $foo{$key}.
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
In reply to Re: Style, style, style
by strat
in thread Style, style, style
by Juerd
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |