diff --git a/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm b/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm index 8290eab..1f27af4 100644 --- a/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm +++ b/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm @@ -23,7 +23,9 @@ sub violates ($self, $elem, $document) { # skip anything that's not a hash key return () unless is_hash_key($elem); - my $k = $elem->literal; + # only some PPI::Token::Quote::* classes implement literal + my $k = $elem->can('literal') ? $elem->literal : $elem->string; + # skip anything that has a special symbol in the content return () unless $k =~ m/^\w+$/; diff --git a/tools/perlcritic b/tools/perlcritic index 80b85b4..07350a9 100755 --- a/tools/perlcritic +++ b/tools/perlcritic @@ -5,6 +5,7 @@ # perlcritic with auto-injection of custom perlcritic rules. use strict; use warnings; +use v5.10; use experimental 'signatures'; use FindBin '$Bin'; @@ -16,5 +17,8 @@ sub extra_include_paths (@extra_paths) { } $ENV{PERL5LIB} = join(':', (extra_include_paths('lib/perlcritic'), $ENV{PERL5LIB} // '')); - +unless (@ARGV) { + say "Usage: $0 files-or-directories"; + exit; +} exec 'perlcritic', @ARGV;