I was about to mention HTML::Mason, which was superior to many other templating solutions back then.
The biggest problem for Perl was that PHP was almost built for the web, while Perl was "just a normal programming language."
I wonder where Perl would have been if there had been a packaged and easy to install version of Apache with Perl, mod_perl, HTML::Mason etc. pre-installed in some way in late 90s.
Mod_perl was too much of a hosting liability for that to have been a possibility. You had to really watch your step with mod_perl not to expose shared memory to other processes running on the same server. Mod_perl is also much more complex than PHP or even Perl CGI. It was always considered senior Perl dev territory whereas PHP was aimed at the lower-tech DIY market.
Mason was great, but it'd have needed to be accompanied with an easy-as-adding-a-different-document-extension scheme installed by default w/ mod_perl on commodity hosting in order to have saved Perl's popularity vs PHP.
The big thing for PHP was how easy it was to go from "I've got a static HTML document that looks like what I want!" to "I've just added a tiny bit of dynamic content by sprinkling in a special tag!" on the majority of unix-based hosts. Deployment was uploading via FTP, just like it was with HTML. There's just so little conceptual distance or friction between static HTML and dynamic document/app, the pit of success is right there to fall into (granted, the peak of further success has some rocky roads out of that pit, but by then you've got momentum!).
On commodity hosting, Perl got typecast as a CGI tool instead. Which had its own power (CGI is kinda the OG serverless)... but not as easy a jumping off spot for anybody who was doing HTML.
It was only high performance if used with mod_perl and that was the problem for cheap hosts. HTML::Mason without mod_perl was a dog compared with PHP. Perl generally missed the boat with embedded templating. Catalyst, Mojolicious and Dancer eventually arrived but by then PHP had won. The Perl community also wasted a lot of energy trying to agree on a de facto way of doing OO. You had Damian Conway keeping it simple with blessed hashrefs on one side and kitchen sink OO with Moose on the other. In between were countless Moose riffs - Moo, Mouse, Mo. Not content with that, others opted for a Meta Object Protocol (MOP) for Perl but none of this stuck enough for Perl to compete with Python and Ruby which had OO built-in. These 2 factors are more or less why Perl lost mindshare when it mattered.
The biggest problem for Perl was that PHP was almost built for the web, while Perl was "just a normal programming language."
I wonder where Perl would have been if there had been a packaged and easy to install version of Apache with Perl, mod_perl, HTML::Mason etc. pre-installed in some way in late 90s.