Perl Style: Parallelism

  • Code legibility is dramatically increased by consistency and parallelism. Compare

        my $filename =    $args{PATHNAME};
        my @names    = @{ $args{FIELDNAMES} };
        my $tab      =    $args{SEPARATOR};
    

    with

        my $filename = $args{PATHNAME};
        my @names = @{$args{FIELDNAMES}};
        my $tab = $args{SEPARATOR};
    
  • Line up your # comments or your || die all at one column:

        socket(SERVER, PF_UNIX, SOCK_STREAM, 0) || die "socket $sockname: $!";
        bind  (SERVER, $uaddr)                  || die "bind $sockname: $!";
        listen(SERVER,SOMAXCONN)                || die "listen $sockname: $!";
    

Forward to Embrace && and || for Control and Values
Back to Length of Variable Names
Up to index

Copyright © 1998, Tom Christiansen All rights reserved.

Tags

Feedback

Something wrong with this article? Help us out by opening an issue or pull request on GitHub