It might look a little magical at first, but it's actually pretty simple. Instead of using a regular expression, I first split the string on ";" and kept only the first bit ((split ";")[0]) to chop off the optional bits. Then I split that first bit on "/" and kept the last part ((split "/", ...)[-1]) to get the value you wanted. Finally, I assigned the result to $_ and used the -p option to print the value.

Oops! The parser sees "print (" and thinks we're wrapping the print arguments in parenthesis, leading to a syntax error later. I could've fixed the problem by putting a unary "+" on the thing to print, as that tells perl that the parenthesis isn't part of print:

But I went a different route: since you're using echo to inject the value into perl as the value $_, I instead elected to use the -p option which tells perl to print the value in $_ after the code executes, giving me the bit of code I suggested.