in reply to Regex explanation

FWIW, it's a poorly crafted regex. It will make false matches; e.g.–

moo@cow>perl -le 'print "MATCH" if +shift =~ /.*\/(.*).lib/' ' /ohai/l +ib/bingo' MATCH moo@cow>perl -le 'print "MATCH" if +shift =~ /.*\/(.*).lib/' 't a c o/ +alibrary.mp4' MATCH

I presume it is meant to match and retain the plain lib name. This is saner but maybe not as good as it gets–

$lib_name =~ s{\A.+/([^/]+)\.lib\z}{$1};

I left out dot-star because you should if you can and if we know there will always be a slash before the lib (/lib) then we can assume there will always be *some* content before the slash (c.f., there is never going to be a volume:/lib dir). Lots more info: perlre.