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 @A=@{$x}; # no (see Configuration)
my @A=@{$x{$k}}; # 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
Unnecessary blockwise casting of the form @{$thing} is a violation and should be written as @$thing. To disable this, set directcast:
[References::RequireSigils]
directcast = 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.
BUGS
This implementation is mostly "Only use arrows for methods", except for "Do not block cast single symbols".
Nested blockwise casting is not considered a violation, eg @{${x}}.
SEE ALSO
See Perl::Critic::Policy::References::ProhibitDoubleSigils to move code away from sigils, but note that does not require postfix dereferencing.