##
$version = quotemeta("3.5.2+tcl-tk-8.5.18+sqlite-3.10.0");
$path =~ s/($version).*/$1/s;
####
$version = "3.5.2+tcl-tk-8.5.18+sqlite-3.10.0";
my $pos = index($path, $version);
# cut everything beyond the match, if there was a match
substr($path, $pos + length($version)) = '' if $pos >= 0;