This is a prime example of a situation in which the effort of Reading The Fine Manual would have been generously rewarded. See the discussion of m/PATTERN/ in Regexp Quote-Like Operators in perlop and in particular the sub-section on "Matching in list context".
There are also tools for elucidating regex behavior. See YAPE::Regexp::Explain for regexes of a vintage no later than Perl 5.6. See also davido's nice Perl Regular Expression Tester, which is very informative about the pattern of the m!/?([^/]+$)! regex of the OP.