Your question isn't a great one for this site. Instead of "Please debug this for me" you should ask a simple, specific how-to question.
Anyway, this will get you started.
(defun myconcat(start end)
"Split region on `,' chars and concatenate the substrings."
(let* ((x (buffer-substring start end))
Eventually this bug has been fixed in the Emacs repository. You can use cperl-mode.el directly from that repository with Emacs 26.1 or newer.
The fix does what could have been done in font-lock-extend-region-functions as suggested by wasamasa and now uses the same method as perl-mode.el to mark here-documents.