#!/usr/bin/env perl use strictures; use URI; use Path::Tiny; my @uris = map URI->new($_), ; for my $uri ( @uris ) { if ( $uri =~ /(\d+)\.htm(l)?$/i ) { print "Naive matched -> $uri\n"; } else { print "Naive rejected -> $uri\n"; } my $file = path( $uri->path )->basename; if ( $file =~ /\A[1-9][0-9]{3}\.html?\z/i ) { print "Robust matched -> $uri\n"; } else { print "Robust rejected -> $uri\n"; } print "\n"; } __DATA__ https://moo.cow/queso/1234.HTM https://www.google.com/search?num=100&q=1234.htm http://moo.cow/queso/1234.htm?so=what#taco #### Naive matched -> https://moo.cow/queso/1234.HTM Robust matched -> https://moo.cow/queso/1234.HTM Naive matched -> https://www.google.com/search?num=100&q=1234.htm Robust rejected -> https://www.google.com/search?num=100&q=1234.htm Naive rejected -> http://moo.cow/queso/1234.htm?so=what#taco Robust matched -> http://moo.cow/queso/1234.htm?so=what#taco