Parametric macro dependency generators are not supported in EPEL 7 and 8's RPM versions. You can still implement this using a "regular" dependency generator. This is also described in the RPM documentation[1]. Instead of specifying %__perlcompat_requires() and writing an RPM macro that accepts a path name as %1, you specify `%__percompat_requires /path/to/executable`. That script receives a newline separated list of paths as stdin and prints the generated dependencies to stdout separated by newlines.
So perlcompat.attr could look something like
%__perlcompat_requires %{_rpmconfigdir}/perlcompat.req %{perl_version} # %%__perlcompat_path can stay the same.
These are usually stored in %%{_rpmconfigdir}. %%{perl_version} is passed to the script as an argument, because the script of course doesn't have access to the RPM context. This can be any executable written in any language, but it should be straightforward to do this in shell.
Thank you for your advice.
The dependency generator would be added to perl-srpm-macros which is in buildroot of Fedora. So, I prepared package perl-srpm-macros-epel which should work for EPEL 7/8/9. If you want to check it please look at https://jplesnik.fedorapeople.org/perl-srpm-macros-epel/
I checked it in Copr https://copr.fedorainfracloud.org/coprs/jplesnik/perl-epel/.
If the change is approved by FESCo, I'll prepared the review for the package. Then I'll ask you for adding it to epel-srpm-macros.
Regards, Jitka