aboutsummaryrefslogtreecommitdiff
path: root/challenge-060/jo-37
diff options
context:
space:
mode:
authorJörg Sommrey <28217714+jo-37@users.noreply.github.com>2020-05-13 18:02:53 +0200
committerJörg Sommrey <28217714+jo-37@users.noreply.github.com>2020-05-13 18:02:53 +0200
commit6de4ab4be336474a1c70e81237d03ca52df76658 (patch)
tree91974cdf01c6f3bc2492f34d98f8fb3eb342eeaa /challenge-060/jo-37
parent4393ea61d3e1d29924cbd193b902bca0082898b6 (diff)
downloadperlweeklychallenge-club-6de4ab4be336474a1c70e81237d03ca52df76658.tar.gz
perlweeklychallenge-club-6de4ab4be336474a1c70e81237d03ca52df76658.tar.bz2
perlweeklychallenge-club-6de4ab4be336474a1c70e81237d03ca52df76658.zip
use string compare
Diffstat (limited to 'challenge-060/jo-37')
-rwxr-xr-xchallenge-060/jo-37/perl/ch-2.pl12
1 files changed, 9 insertions, 3 deletions
diff --git a/challenge-060/jo-37/perl/ch-2.pl b/challenge-060/jo-37/perl/ch-2.pl
index 128128876a..86172c303f 100755
--- a/challenge-060/jo-37/perl/ch-2.pl
+++ b/challenge-060/jo-37/perl/ch-2.pl
@@ -7,7 +7,7 @@
# See below.
#
# Performs recursive "branch and cut".
-# Though data is numeric, processing is string based.
+# Though data is numeric, processing is strictly string based.
use Test2::V0;
use Data::Dumper;
@@ -20,7 +20,7 @@ use Data::Dumper;
sub check_num {
my $num = shift;
my $ctl = shift;
- if ($num < $ctl->{limit}) {
+ if ($num lt $ctl->{limit}) {
return $ctl->{result}{$num} = 1
};
0;
@@ -43,7 +43,7 @@ sub gen_num {
# loop over parts at this level
foreach my $num (@{$ctl->{parts}}) {
# skip leading zero
- next if $num == 0 && $level == 0;
+ next if $num eq 0 && $level == 0;
$current[$level] = "$num";
my $stop;
@@ -110,3 +110,9 @@ done_testing;
$X = 5;
$Y = 70001;
print Dumper [create_numbers $X, $Y, @L];
+
+# non-numeric
+@L = qw(a b c);
+$X = 3;
+$Y = 'abc';
+print Dumper [create_numbers $X, $Y, @L];