Section 5.11. Slice Layout


5.11. Slice Layout

Use a tabular layout for slices.

A slice-to-slice assignment like:

      @frames[-1,-2,-3]         = @active{'top', 'prev', 'backup'};

can also be written as:

        @frames[ -1,    -2,     -3     ]     = @active{'top', 'prev', 'backup'};

This second version makes it immediately apparent which hash entry is being assigned to which array element. Unfortunately, this approach is useful only when the number of keys/indices in the slices is small. As soon as either list exceeds a single line, the readability of the resulting code is made much worse by vertical alignments:

       @frames[ -1,    -2,     -3,      -4,          -5,      -6,                -7,          -8     ]     = @active{'top', 'prev', 'backup', 'emergency', 'spare', 'rainy day',               'alternate', 'default'};



Perl Best Practices
Perl Best Practices
ISBN: 0596001738
EAN: 2147483647
Year: 2004
Pages: 350
Authors: Damian Conway

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net