aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-10-03 13:15:26 +0100
committerGitHub <noreply@github.com>2022-10-03 13:15:26 +0100
commit652873b66d6eb7c22a64aae48fec590fca58e8b0 (patch)
tree1b8435142286f2be967e38c454ad23568387cbe6
parent4088ee2cace762398148b727db34e40b219d4e97 (diff)
parent107ac6f42f514b028797bfd00e513714e2d34e7a (diff)
downloadperlweeklychallenge-club-652873b66d6eb7c22a64aae48fec590fca58e8b0.tar.gz
perlweeklychallenge-club-652873b66d6eb7c22a64aae48fec590fca58e8b0.tar.bz2
perlweeklychallenge-club-652873b66d6eb7c22a64aae48fec590fca58e8b0.zip
Merge pull request #6834 from davorg/master
Challenge #185
-rw-r--r--challenge-185/dave-cross/perl/ch-1.pl14
-rw-r--r--challenge-185/dave-cross/perl/ch-2.pl20
2 files changed, 34 insertions, 0 deletions
diff --git a/challenge-185/dave-cross/perl/ch-1.pl b/challenge-185/dave-cross/perl/ch-1.pl
new file mode 100644
index 0000000000..ce3b004799
--- /dev/null
+++ b/challenge-185/dave-cross/perl/ch-1.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+my $in = shift;
+
+my $hex_re = qr/[a-f0-9]/i;
+
+die "$in is not a valid MAC address\n"
+ unless $in =~ /^$hex_re{4}\.$hex_re{4}\.$hex_re{4}$/;
+
+say join ':', $in =~ /($hex_re{2})/g;
diff --git a/challenge-185/dave-cross/perl/ch-2.pl b/challenge-185/dave-cross/perl/ch-2.pl
new file mode 100644
index 0000000000..f2aab1003b
--- /dev/null
+++ b/challenge-185/dave-cross/perl/ch-2.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+for my $in (@ARGV) {
+ my $x = 0;
+
+ for (0 .. length($in) - 1) {
+ if (substr($in, $_, 1) =~ /[a-z0-9]/) {
+ substr $in, $_, 1, 'x';
+ ++$x;
+ }
+
+ last if $x == 4;
+ }
+
+ say $in;
+}