in reply to Using variable in substitute regex producing odd results

You may want to look at \Q \E operators:
... $line =~ s/\Q$delimiter/\,/g; ...