From 67fa300cfb8f08e4f26724501484b281949cf654 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 2 Jan 2021 19:32:07 +1300 Subject: Use prototype refs rather than literal values Recommended by Effective Perl Programming, and I think it's good. --- lib/List/Breakdown.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/List/Breakdown.pm b/lib/List/Breakdown.pm index 04aa4ce..7a32fa5 100644 --- a/lib/List/Breakdown.pm +++ b/lib/List/Breakdown.pm @@ -24,16 +24,16 @@ my %types = ( # If it's a hash, apply breakdown() again as if it were another root-level # spec - HASH => sub { + ref {} => sub { my $spec = shift; return { breakdown( $spec, @_ ) }; }, # If it's an array, we're doing numeric bounds checking [a,b) - ARRAY => sub { + ref [] => sub { my $bounds = shift; @{$bounds} == 2 - or croak 'ARRAY ref for bounds needs two items'; + or croak 'arrayref for bounds needs two items'; return [ grep { ( not defined $bounds->[0] or $_ >= $bounds->[0] ) @@ -44,14 +44,14 @@ my %types = ( # If it's a subroutine, return a arrayref of all elements for which it # returns true - CODE => sub { + ref sub { } => sub { my $sub = shift; return [ grep { $sub->() } @_ ]; }, # If it's a regular expression, return an arrayref of all elements it # matches - Regexp => sub { + ref qr//msx => sub { my $re = shift; return [ grep { $_ =~ $re } @_ ]; }, @@ -63,8 +63,8 @@ sub breakdown { my ( $spec, @items ) = @_; # Check the spec is a hashref - ref $spec eq 'HASH' - or croak 'HASH ref expected for first argument'; + ref $spec eq ref {} + or croak 'hashref expected for first argument'; # Start building a results hash my %results; -- cgit v1.2.3 From 1b43b649295dfcf98b388cb3d9c154b5821cc351 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 2 Jan 2021 19:40:47 +1300 Subject: Add perlcriticrc --- perlcriticrc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 perlcriticrc diff --git a/perlcriticrc b/perlcriticrc new file mode 100644 index 0000000..db52151 --- /dev/null +++ b/perlcriticrc @@ -0,0 +1,7 @@ +severity = brutal +[-Compatibility::PodMinimumVersion] +[-Documentation::RequirePODUseEncodingUTF8] +[-Editor::RequireEmacsFileVariables] +[-ErrorHandling::RequireUseOfExceptions] +[-ValuesAndExpressions::RequireConstantOnLeftSideOfEquality] +[-Variables::ProhibitLocalVars] -- cgit v1.2.3