NAME
Perl::Critic::Policy::References::RequireSigils - Only use dereferencing arrows for method calls; use sigils to signal types.
DESCRIPTION
Post-conditional and post-fix operators are harder to read and maintain, especially within other operators and functions that work only in infix or prefix/function-call mode. Since certain forms of arrow-dereferencing don't work inside quoted constructs, there can be additional confusion about uniformity of expected behaviors:
print "Name: ",$href->{name} # no
print "Name: ",$$href{name} # yes
print "Item: ",$aref->[1] # no
print "Item: ",$$aref[1] # yes
my @A=$x->@*; # no
my @A=@$x; # yes
my $y=$x->method(); # yes
print "$x->method();" # invalid code (not checked)
print "Name: $href->{name}" # no
print "Name: $$href{name}" # yes
print "Item: $aref->[1]" # no
print "Item: $$aref[1]" # yes
CONFIGURATION
Violations within interpolated strings can be disabled by setting interpolation:
[References::RequireSigils]
interpolation = 0
NOTES
Not presently well-tested. There may be some false violations.
Inside Quote/QuoteLike expressions, String::InterpolatedVariables will be used in the future to establish consistency.
Proposed: Because @$x is a direct casting operation, whereas @{ $x } is a block operator, performance goals may suggest that the latter is a violation of the expected pattern for sigils. In particular it signals "there is a complicated expansion here", when it fact it is just meant as a direct casting operator. Future configuration may support enabling required double sigils where possible.
BUGS
This implementation is primarily "Prohibit non-method arrows" at this time.
SEE ALSO
See Perl::Critic::Policy::References::ProhibitDoubleSigils to move code away from sigils, but note that does not require postfix dereferencing.