Perl::Critic::Policy::ValuesAndExpressions::ProhibitSingleArgArraySlice - Prohibit using an array slice with only one index
When using an array slice
@foo, you can retrieve multiple values by giving more than one index. Sometimes, however, either due to typo or inexperience, we might only provide a single index.
Perl warns you about this, but it will only do this during runtime. This policy allows you to detect it statically.
# scalar context, single value retrieved my $one_value = $array[$index]; # ok # List context, multiple values retrieved my @values = @array[ $index1, $index2 ] # ok # Scalar context, single value retrived (the last item in the array) # Perl will warn you, but only in runtime my $value = @array[$index]; # not ok
This policy is not configurable except for the standard options.
Sawyer X <email@example.com>
This software is Copyright (c) 2016 by Sawyer X.
This is free software, licensed under:
The MIT (X11) License