in reply to Use function as a regex

You can use a reference-dereference trick, or the experimental postponed regular subexpression.
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; { package Re; sub re { qr/perl/i } } say 'perl Perl PERL' =~ /${ \Re::re() }/g; say 'perl Perl PERL' =~ /(??{ Re::re() })/g;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Use function as a regex
by salva (Canon) on Feb 15, 2018 at 16:59 UTC
    say 'perl Perl PERL' =~ /${ \Re::re() }/g;

    Abusing the internal representation of regular expressions, this also seems to work:

    say 'perl Perl PERL' =~ /${Re::re()}/g;