in reply to match repetetion of character

You can efficiently count the number of occurrences of one character with the transliteration operator:
use strict; use warnings; my $mail = 'xqwertyxyx@gmail.com'; my $count = ($mail =~ tr/x/x/); print "$count\n";