in reply to Cleaning %PATH% with WinBatch
I don't think this addresses your issue but seems generally relevant and maybe useful to know.
Substrings can be removed using the idiom below.
set PATH=%PATH:C:\perls\strawberry-perl-5.32.1.1-64bit-portable\perl\b +in;=%
A looped example and some gotchas are in this SO post.
In Section
Seekers of Perl Wisdom