View on
MetaCPAN
Tomasz Konojacki > Perl-Critic-Policy-References-ProhibitComplexDoubleSigils-0.2 > Perl::Critic::Policy::References::ProhibitComplexDoubleSigils

Download:
Perl-Critic-Policy-References-ProhibitComplexDoubleSigils-0.2.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.2   Source  

NAME ^

Perl::Critic::Policy::References::ProhibitComplexDoubleSigils - allow $$foo but not $$foo[1]->{dadsdas}->[7].

DESCRIPTION ^

This Perl::Critic policy is very similar to Perl::Critic::Policy::References::ProhibitDoubleSigils but it allows non-complex double sigil dereferences, for details see EXAMPLES and RATIONALE sections.

EXAMPLES ^

    # These are allowed:
    my @array = @$arrayref;
    my %hash = %$hashref;
    my $scalar = $$scalarref;

    for (@$arrayref) {
        ...
    }

    # These are not:
    my $scalar = $$arrayref[0]->{foobar}; # use these instead:
                                          # $arrayref->[0]->{foobar}
                                          # ${$arrayref}[0]->{foobar}

    my $scalar = $$hashref{bar}->[1]; # use these instead:
                                      # $hashref->{bar}->[1]
                                      # ${$hashref}{bar}->[1]

    &$coderef()->{1234}->[1]; # use these instead:
                              # $coderef->()->{1234}->[1]
                              # &{$coderef}()->{1234}->[1]

    ...

RATIONALE ^

There are some cases when using braces in dereferences makes sense, I don't deny it, but in my opinion it reduces code readability in most common cases. Perl::Critic::Policy::References::ProhibitDoubleSigils is simply too strict. Consider following examples:

    # exhibit A:
    for (@{$foo}) {
        ...
    }

    # exhibit B:
    for (@$foo) {
        ...
    }

If you think that B is more legible, this critic policy is for you.

CAVEATS ^

Enabling both Perl::Critic::Policy::References::ProhibitDoubleSigils and this policy is not a very wise choice.

EXPORT ^

None by default.

FOSSIL REPOSTIORY ^

Perl::Critic::policy::References::ProhibitComplexDoubleSigils Fossil repository is hosted at xenu.tk:

    http://code.xenu.tk/repos.cgi/prohibit-complex-double-sigils

SEE ALSO ^

AUTHOR ^

Tomasz Konojacki <me@xenu.tk>, http://xenu.tk

COPYRIGHT AND LICENSE ^

Copyright (C) 2015 Tomasz Konojacki

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.20.1 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: