Right you are!
It seemed to me that without that terminator the document being passed to the PPI::Document->new() would fail to parse. But having tried your recommendation --- I got what was expected! So with your change the script can be used to Find-And-Replace-HereDocs. Modify to suit yourself and enjoy!