aboutsummaryrefslogtreecommitdiff
path: root/challenge-018
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-01-26 23:31:20 +0000
committerPaulo Custodio <pauloscustodio@gmail.com>2021-01-26 23:31:20 +0000
commit8f7f5c93def45398db496f35e7921cfe0d264d1d (patch)
tree7f141de93b08d38f0e5fc5930ec93fc4ef311638 /challenge-018
parent8902910406fe11ec55932be70d1df508f61c083d (diff)
downloadperlweeklychallenge-club-8f7f5c93def45398db496f35e7921cfe0d264d1d.tar.gz
perlweeklychallenge-club-8f7f5c93def45398db496f35e7921cfe0d264d1d.tar.bz2
perlweeklychallenge-club-8f7f5c93def45398db496f35e7921cfe0d264d1d.zip
Remove List::Util and Data::Dump dependencies
Diffstat (limited to 'challenge-018')
-rw-r--r--challenge-018/paulo-custodio/perl/ch-1.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/challenge-018/paulo-custodio/perl/ch-1.pl b/challenge-018/paulo-custodio/perl/ch-1.pl
index a7c7d65c34..b79fbe788b 100644
--- a/challenge-018/paulo-custodio/perl/ch-1.pl
+++ b/challenge-018/paulo-custodio/perl/ch-1.pl
@@ -12,7 +12,6 @@
use strict;
use warnings;
use 5.030;
-use List::Util 'all';
say "(", join(", ", map {$_=qq("$_")} longest_substr(@ARGV)), ")";
@@ -28,7 +27,7 @@ sub longest_substr {
next if $longest_len > $len; # prune search
my $substr = substr($str, $s, $len);
next if $longest{$str}; # prune search
- if (all {/$substr/} @strs) { # matches all
+ if (all(sub {/$substr/}, @strs)) { # matches all
if ($longest_len == $len) {
$longest{$substr}=1;
}
@@ -42,3 +41,9 @@ sub longest_substr {
}
return sort keys %longest;
}
+
+sub all {
+ my($sub, @a) = @_;
+ for (@a) { return if !$sub->($_); }
+ return 1;
+}