in reply to Re: Calculate prime factors for a given number in a perl one-liner
in thread Calculate prime factors for a given numer in a perl one-liner

I hadn't previously encountered this piece of (lateral|perversity of) thought and so I played about with it a bit. I noticed that once the regex encounters a match greater than 2^16 in length it stops matching. (eg run the command with the argument 131072 (2^17) ).

Is this a limit of the non-greedy match in regex that I am encountering?

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
  • Comment on Re^2: Calculate prime factors for a given numer in a perl one-liner
  • Download Code

Replies are listed 'Best First'.
Re^3: Calculate prime factors for a given numer in a perl one-liner
by moritz (Cardinal) on Dec 16, 2010 at 09:22 UTC

    I didn't investigate it thoroughly, but I think it's not the non-greediness. Rather the + in the regex is compiled to {1,32767}, which is a general limit of the 16 bit heritage of the regex engine.