Sure.
Firstly, using the substitution operator (s/.../.../) here is the wrong tool. You can use the match operator (m/.../) to just extract the bit of the string that you want.
echo $URL | perl -pe 'm/https\:\/\/drive.google.com\/file\/d\/(\w+)/ and $_ = $1'
Here, we're using "capturing parentheses" to copy the string of "word characters" (alphanumerics and the underscore) that follows the /d/ in the URL into the variable $1. We then copy that into $_ as that's the variable that -p will automatically print.
But we can do better than that. Both s/.../.../ and m/.../ allow us to change our delimiters, so that we don't have to escape all of those slashes.
echo $URL | perl -pe 'm[https://drive.google.com/file/d/(\w+)] and $_ = $1'
We can use print directly to remove the slightly confusing variable assignment at the end.
echo $URL | perl -ne 'print m[https://drive.google.com/file/d/(\w+)]'
And, if we know that our input data is always going to look like the current example, there's really no need to include so much of the URL.
echo $URL | perl -ne 'print m[/d/(\w+)]'
Update: You've got a comment suggesting that you use the URI module to parse your string. I'm not convinced that's particularly useful as the module will give you the path part of your URL and you still need to extract the correct part of the path. But, for completeness, here's an example using that module:
echo $URL | perl -MURI -ne 'print +(URI->new($_)->path_segments)[3]'
We create a URI object from our input and immediately call its path_segments() method to get the segments of the path. We print the fourth element of the list that is returned.