aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-08-17 12:29:13 +0100
committerGitHub <noreply@github.com>2021-08-17 12:29:13 +0100
commit11790f0764825e88a83f7c23b03319c4257b81cb (patch)
treee523b853e6ab1f88f2b20caf4bdab87f47789fec
parent98fd79b532d89799663b9dd0183581689e75fca2 (diff)
parent8c9ede5b36bcca1030ec86cee0e0bb9c60381f1c (diff)
downloadperlweeklychallenge-club-11790f0764825e88a83f7c23b03319c4257b81cb.tar.gz
perlweeklychallenge-club-11790f0764825e88a83f7c23b03319c4257b81cb.tar.bz2
perlweeklychallenge-club-11790f0764825e88a83f7c23b03319c4257b81cb.zip
Merge pull request #4736 from corvettes13/patch-3
Create ch-1.pl
-rw-r--r--challenge-126/paul-fajman/perl/ch-1.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-126/paul-fajman/perl/ch-1.pl b/challenge-126/paul-fajman/perl/ch-1.pl
new file mode 100644
index 0000000000..9970f0f991
--- /dev/null
+++ b/challenge-126/paul-fajman/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+# Weekly Challenge 126 Task #1
+# You are given a positive integer $N.
+# Write a script to print count of numbers from 1 to $N that don’t contain digit 1.
+
+use strict;
+use warnings;
+
+die "\nPlease provide positive integer for input\n" if (!@ARGV);
+my $number = $ARGV[0];
+my $i;
+
+my @nums = (2..$number); # Create array of numbers from 2 up to user input number.
+my @final = grep(!/1/, @nums); # Create new array not including numbers that have a 1.
+
+my $count = scalar @final; # Get length of new array.
+
+print "Input: \$N = $number\n";
+print "Output: $count\n\n";
+
+print "There are $count numbers between 1 and $number that don't contain the digit 1\n";
+print "@final\n";