#!/usr/bin/perl use warnings; use strict; use URI; use Test::More tests => 2; my %expect = ( '/blah1/blah2/blah3/1234567890;arg=AAA123BBB456CCC' => '1234567890', '/blah1/blah2/blah3/1234567890' => '1234567890'); for my $string (keys %expect) { my $uri = ('URI'->new($string)->path_segments)[-1]; is $uri, $expect{$string}; }