use Path::Tiny qw/ path /; print path( qw[ /ro/sham/bo ] )->basename; __END__ bo