Skip Menu |

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information
The Basics
Id: 15735
Status: resolved
Priority: 0/
Queue: Perl-Tidy

People
Owner: Nobody in particular
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Request: Hanging ternary style
In Damian Conway's book, Perl Best Practices, he advocates structuring if-elsif-else lists like this example: #Load profile in various ways my $user_prefs = $ref_type eq 'SCALAR' ? _load_from_string( $profile ) : $ref_type eq 'ARRAY' ? _load_from_array( $profile ) : $ref_type eq 'HASH' ? _load_from_hash( $profile ) : _load_from_file( $profile ); I request a new feature in Perl::Tidy that supports this indentation. Thanks for an enormously useful module! -- Chris
From: cdolan [...] cpan.org
Sorry, I just reread the above and discovered that I was unclear. The part that P::T currently does not seem to support is the indentation of the final else in the ternary. That is, the above becomes the following: #Load profile in various ways my $user_prefs = $ref_type eq 'SCALAR' ? _load_from_string($profile) : $ref_type eq 'ARRAY' ? _load_from_array($profile) : $ref_type eq 'HASH' ? _load_from_hash($profile) : _load_from_file($profile); The first lines are fine, but the last line is not sufficiently indented. -- Chris
Chris, I couldn't get this into the latest release but it is still (high) on the wish list. Thanks, Steve On Sat Nov 12 15:51:07 2005, CLOTHO wrote: Show quoted text
> Sorry, I just reread the above and discovered that I was unclear. The > part that P::T currently does not seem to support is the indentation of > the final else in the ternary. That is, the above becomes the following: > > #Load profile in various ways > my $user_prefs = > $ref_type eq 'SCALAR' ? _load_from_string($profile) > : $ref_type eq 'ARRAY' ? _load_from_array($profile) > : $ref_type eq 'HASH' ? _load_from_hash($profile) > : _load_from_file($profile); > > The first lines are fine, but the last line is not sufficiently indented. > -- Chris
This is implemented in version 20060719 if the final term is somewhat similar to the previous terms, as in the example. Some further improvements will be made in future versions. Steve Show quoted text
> On Sat Nov 12 15:51:07 2005, CLOTHO wrote:
> > Sorry, I just reread the above and discovered that I was unclear. The > > part that P::T currently does not seem to support is the indentation of > > the final else in the ternary. That is, the above becomes the
following: Show quoted text
> > > > #Load profile in various ways > > my $user_prefs = > > $ref_type eq 'SCALAR' ? _load_from_string($profile) > > : $ref_type eq 'ARRAY' ? _load_from_array($profile) > > : $ref_type eq 'HASH' ? _load_from_hash($profile) > > : _load_from_file($profile); > > > > The first lines are fine, but the last line is not sufficiently
indented. Show quoted text
> > -- Chris
>