Perl Christmas Quiz 2009

James Coupe james at
Tue Dec 1 00:51:10 GMT 2009

James Coupe <james at> wrote:
>$ perl -e '("1" x $ARGV[0]) =~ m/^(1*)((??{$1x(length($1)-1)})$)(?(2)(?{print length $1}))/' 4
>I don't recommend trying it on large numbers.  1024 was about as high as
>my boredom threshold could tolerate on this box.

Oh, it gets better if I do something _sensible_ and make the (1*)
non-greedy - so (1*?).  Duh.

James Coupe

More information about the mailing list