Re: Code Format Question
From: "Darryl Schnell" <[EMAIL PROTECTED]> > This may not be the place to ask this question so forgive me. I know a > few people who are obsessed with the way their perl code is formatted > and I was wondering what does actual good readable perl code and bad > formatted perl code look like? You know you see a badly formated code when you see it. But there are several good formating styles and choosing one is (if you are lucky) just a matter of personal taste or (if not so lucky) a matter of coding style in your company. But there is not one provably best style. > I usually have my code looking something like this: > > (Note not a real program just my formatting style). > > if ($action eq "Submit") { > $value =1; > $value =2; > if ($testus = "2") { > $testus = 6; > } > } > > Would the above code be considered poorly formatted? This is very close to how I would format it. Just two unimportant notes. 1) I would (if I cared about formating, which I sometimes forget) put a space after the = in $value = 1; 2) I'd probably use $testus = 6 if $testus == 2; or $testus = 6 if $testus == 2; (I guess the single = in the condition was a typo :) Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Code Format Question
Hi, I prefer using the other form of if/unless etc when possible. And I run under 'use strict;', hence I properly localise my variables. I.e. if ($action eq "Submit") { my ($value, $value) = (1, 2); $testus = 6 if ($testus eq "2"); } > but I think what you wrote can be considered following > some kind of code standard pretty widely adepted. It can be easy to get into code styling wars... my advice is to pick one and stick with it. Have a look at: perldoc perlstyle and: The jargon file entry under "indent style", which you can find at: http://suse.eyjar.is/download/mirrors/jargon-4.2.0/jargon.html Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Code Format Question
Darryl Schnell wrote: > > This may not be the place to ask this question so forgive me. I know a few people >who are obsessed with the way their perl code is formatted and I was wondering what >does actual good readable perl code and bad formatted perl code look like? > > I usually have my code looking something like this: > > (Note not a real program just my formatting style). > > if ($action eq "Submit") { > $value =1; > $value =2; > if ($testus = "2") { > $testus = 6; > } > } > > Would the above code be considered poorly formatted? > i think that was nicely formatted code. i usually put { on the next line becouse i find it easier to see where the scope is: if ($action eq "Submit") { $value = 1; $value = 2; if ($testus = "2") { $testus = 6; } } but i think what you wrote can be considered following some kind of codestandard pretty widely adepted. /Jon > Any comments are welcome. > > Thanks, > Darryl > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]