use strict; use warnings; use URI; my $uri = URI->new( $ENV{REQUEST_URI} ); my $page = ($uri->path_segments)[-2]; #### my $page = (map $_ ? $_ : (), $uri->path_segments)[-1];