Greetings,
Why does the last test fail?
#!/usr/bin/perl
use Regexp::Common qw/ net number /;
use Test::More;
use strict;
use warnings;
my $valid_host = qr/\A
(?: $RE{net}{IPv6} ) |
(?: $RE{net}{IPv4} ) |
(?: $RE{net}{domain}{-nospace}{-rfc1101}\.? )
\Z/x;
like('luna.example.com', $valid_host, 'valid long hostname' );
like('luna', $valid_host, 'valid short hostname' );
like('fe80::42:5eff:feef:8f4f', $valid_host, 'valid ipv6 ip' );
like('10.0.0.1', $valid_host, 'valid ipv4 ip' );
unlike('10.0 24', $valid_host, 'invalid host or ip' );
done_testing;
ok 1 - valid long hostname
ok 2 - valid short hostname
ok 3 - valid ipv6 ip
ok 4 - valid ipv4 ip
not ok 5 - invalid hostname or ip
# Failed test 'invalid hostname or ip'
# at /home/neil/src/neil/test/ipv4.pl line 22.
# '10.0 24'
# matches '(?^x:\A
#
....
#
# \Z)'
1..5
# Looks like you failed 1 test of 5.