I looked through past messages and didn't see a similar issue (though I don't doubt that it did and I just missed it). I updated and upgraded Homebrew and reinstalled perl but got exactly the same error. Here is the output again and, below that, is info on my perl version.
brew info perl
==> perl: stable 5.40.1 (bottled), HEAD
Highly capable, feature-rich programming language
https://www.perl.org/Installed
/opt/homebrew/Cellar/perl/5.40.1 (2,781 files, 69.9MB) *
Poured from bottle using the
formulae.brew.sh API on 2025-03-28 at 08:56:41
From:
https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/perl.rbLicense: Artistic-1.0-Perl OR GPL-1.0-or-later
==> Dependencies
Required: berkeley-db@5 ✔, gdbm ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
By default non-brewed cpan modules are installed to the Cellar. If you wish
for your modules to persist across updates we recommend using `local::lib`.
You can set that up like this:
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
And add the following to your shell profile e.g. ~/.profile or ~/.zshrc
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
==> Analytics
install: 14,196 (30 days), 51,422 (90 days), 196,004 (365 days)
install-on-request: 4,053 (30 days), 16,105 (90 days), 57,847 (365 days)
build-error: 10 (30 days)