aboutsummaryrefslogtreecommitdiff
path: root/challenge-135/abigail/perl/ch-1.pl
blob: 878d686567a86f4283c0ebf0114bd344ca98f737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/opt/perl/bin/perl

use 5.032;

use strict;
use warnings;
no  warnings 'syntax';

use experimental 'signatures';
use experimental 'lexical_subs';

#
# See ../README.md
#

#
# Run as: perl ch-1.pl < input-file
#

while (<>) {
    say /^[-+]?([0-9]*)([0-9]{3})([0-9]*)$
        (??{length ($1) == length ($3) ? "" : "(*FAIL)"})/x
                                  ? $2
      : /^[-+]?[0-9]*[^0-9].*\n/  ? "not an integer"
      : /^[-+]?(?:[0-9][0-9])*\n/ ? "even number of digits"
      :                             "too short"
}

__END__