One good suggestion is that of
nefigah, who suggests using Perl to do the same things as the PHP does. Now, if that's not an option, then another is to convert your application to one that uses templates, such as
HTML::Template or the
Template Toolkit. Then the PHP code would reside in the template itself and your Perl can just add the dynamic content to the template in use.