my $str ='/something/more words
'; my @bits = $str =~ m!()/([^/]+)/([^/]+)
()!; print $_,$/ for @bits;