What's the maximum number of numbered regex captures?

前端 未结 1 1900
无人及你
无人及你 2021-01-11 13:17

I\'m maintaining some code that reads values over a serial radio and unpacks them into Perl data structures:

# Don\'t yell at me, I didn\'t write this
if (         


        
1条回答
  •  一生所求
    2021-01-11 13:49

    This script works up to at least $N=5000000. After that, it runs out of memory.

    $N = $ARGV[0] || 5000;
    $q = '(.)' x $N;
    $regex = qr/$q/;
    ("x" x $N) =~ $regex;
    print eval "\$$N";
    

    0 讨论(0)
提交回复
热议问题