Perl::Critic::Policy::References::ProhibitComplexDoubleSigils - allow $$foo but not $$foo[1]->{dadsdas}->[7].
$$foo
$$foo[1]->{dadsdas}->[7]
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.
# 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] ...
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.
B
Enabling both Perl::Critic::Policy::References::ProhibitDoubleSigils and this policy is not a very wise choice.
None by default.
Perl::Critic::policy::References::ProhibitComplexDoubleSigils Fossil repository is hosted at xenu.tk:
http://code.xenu.tk/repos.cgi/prohibit-complex-double-sigils
Perl::Critic
Perl::Critic::Policy::References::ProhibitDoubleSigils
Tomasz Konojacki <me@xenu.tk>, http://xenu.tk
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.
To install Perl::Critic::Policy::References::ProhibitComplexDoubleSigils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::Policy::References::ProhibitComplexDoubleSigils
CPAN shell
perl -MCPAN -e shell install Perl::Critic::Policy::References::ProhibitComplexDoubleSigils
For more information on module installation, please visit the detailed CPAN module installation guide.