Perl Christmas Quiz 2009

James Coupe james at zephyr.org.uk
Tue Dec 1 00:51:10 GMT 2009


James Coupe <james at zephyr.org.uk> wrote:
>$ perl -e '("1" x $ARGV[0]) =~ m/^(1*)((??{$1x(length($1)-1)})$)(?(2)(?{print length $1}))/' 4
>2
>
>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 london.pm mailing list