in reply to set value of a variable to a regexp

You can use the qr// operator, that even works with modifiers:

my $regex = qr/(.)\1+/i; @ret = grep m/$regex/, @values;

But for me your code works as well.

(Update: removed p6ism, tinita++)