use 5.010; use URI; use List::MoreUtils qw(first_index); for my $uri (qw( http://www.chi.com/business/world/us-microsoft-reorganization.story http://www.chi.com/business/sns-rt-us-markets-stocks.story http://www.chi.com/business/sns-rt-us-bank-capital-us.story http://www.chi.com/business/sns-rt-us-bank-capital.story )) { say $uri; my @segments = grep { $_ } URI->new($uri)->path_segments; say for splice @segments, 0, (first_index { /-/ } @segments); }