aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2021-01-02 19:32:07 +1300
committerTom Ryder <tom@sanctum.geek.nz>2021-01-02 19:41:10 +1300
commit67fa300cfb8f08e4f26724501484b281949cf654 (patch)
tree3d9d8baf4e8cce87aee421a985c6ac8183756ca0
parentMerge branch 'release/v0.22' (diff)
downloadList-Breakdown-67fa300cfb8f08e4f26724501484b281949cf654.tar.gz
List-Breakdown-67fa300cfb8f08e4f26724501484b281949cf654.zip
Use prototype refs rather than literal values
Recommended by Effective Perl Programming, and I think it's good.
-rw-r--r--lib/List/Breakdown.pm14
1 files 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;