[Chicago-talk] Perl Style
Scott T. Hildreth
shild at sbcglobal.net
Thu Aug 19 17:47:07 CDT 2004
I used to be a die hard user of
sub foo
{
}
then one day,
sub foo {
}
became my favorite. I think it was Tim Bunce that converted me, I was
coding some 'C' for him, and to be consistent I was using this style and
started liking it. I use it for Sql as well.
i.e.
Create Table Foo (
)
or
$dbh->selectall_arrayref(q{
Select blah
From foo
Where bar = ?
}, undef, value);
...etc.
I never do this in Perl (I did when coding 'C'),
if (value) { $a = 1; }
always,
$a = 1 if value;
...anyway just my addition to the style thread...
On Thu, 2004-08-19 at 12:35, Steven Lembark wrote:
> > 1) variable names
>
> as a longtime C hacker I use underscores;
> iDontFindThisFormatAnyEasierToRead.
>
> > 2) function names
>
> sub foo
> {
> indented text w/in function
> }
>
> foo "arguments", "to", "foo";
>
>
> > 3) the "{" after a function
>
> I don't snuggle braces, tend to leave things vertical
> on separate lines: easier to see and edit.
>
> if( whatever )
> {
> }
> elsif( whatever else )
> {
> }
> else
> {
> }
>
> or
>
> if
> (
> some &&
> some more &&
> even more yet &&
> yet ever more
> )
> {
> block
> }
>
> or
>
> map { oneliner }
>
> map
> {
> longer
> map
> with
> multiple
> lines
> become
> easier
> to
> edit
> if
> not
> snuggled
> }
>
> > anything else in particular
>
> Take a look at FindBin::libs or Schedule::Depend for lots
> of examples, NEXT::init was on the mailing list last week.
>
> Most of the people who've had to hack my code found it readable.
>
More information about the Chicago-talk
mailing list