diff options
| -rw-r--r-- | challenge-135/steven-wilson/perl/ch-1.pl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-135/steven-wilson/perl/ch-1.pl b/challenge-135/steven-wilson/perl/ch-1.pl new file mode 100644 index 0000000000..b6c6e0775d --- /dev/null +++ b/challenge-135/steven-wilson/perl/ch-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +# Week 135 Task 1 +# Middle 3 digits + +use strict; +use warnings; +use feature qw/ say /; + +my $input = $ARGV[0]; +$input =~ s/^\-//; +my $input_length = length $input; + +( $input_length % 2 ) != 0 or die "even number of digits\n"; +$input_length >= 3 or die "too short\n"; + +say substr $input, ( $input_length / 2 ) - 1, 3; |
