aboutsummaryrefslogtreecommitdiff
path: root/lib/List/Breakdown.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/List/Breakdown.pm')
-rw-r--r--lib/List/Breakdown.pm21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/List/Breakdown.pm b/lib/List/Breakdown.pm
index 7d396a8..319485e 100644
--- a/lib/List/Breakdown.pm
+++ b/lib/List/Breakdown.pm
@@ -1,4 +1,3 @@
-## no critic (RequirePODUseEncodingUTF8)
package List::Breakdown;
# Force me to write this properly
@@ -14,10 +13,10 @@ use Carp;
# Handle exporting in a way Perl v5.6 should tolerate
use base qw(Exporter); ## no critic (ProhibitUseBase)
-our @EXPORT_OK = 'breakdown';
+our @EXPORT_OK = qw(breakdown);
# Specify package version
-our $VERSION = '0.19';
+our $VERSION = '0.26';
# Dispatch table of functions to handle different ref types for the spec
# hashref's values
@@ -25,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] )
@@ -45,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 } @_ ];
},
@@ -64,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;
@@ -104,7 +103,7 @@ List::Breakdown - Build sublist structures matching conditions
=head1 VERSION
-Version 0.19
+Version 0.26
=head1 SYNOPSIS