(This appears to be a followup to the OP's very recent thread.)
@delimiter_to_remove=~s/\$delimiter_used/\n/g;
There are four problems in that line.
- s/// operates on a scalar, not an array. Thus the "Can't modify array dereference in substitution (s///)" error message. Considering your array always contains a single element, I don't know why you have an array at all.
- Escaping the "$" is exactly what you don't want to do. You want interpolation to occur.
- $delimiter_used holds a string, not a regexp. You can convert from one to the other using \Q..\E or quotemeta.
- Newlines are pretty much the same thing as spaces in HTML, so I think you want to use <br> rather than \n as the replacement.
Fix:
$data_to_read =~ s/\Q$delimiter_used\E/<br>/g;
Or if you plan on having more than one element in @delimiter_to_remove,
s/\Q$delimiter_used\E/<br>/g for @delimiter_to_remove;