in reply to match repetetion of character

If you want to get the frequencies of all the letters in the name rather than just one in particular then use a hash and split. Here I have assumed that you are only interested in the name part of the address.

use strict; use warnings; my $addr = q{xqwertyxyx@gmail.com}; my ( $name ) = $addr =~ m{^([^@]+)}; my %letterFreq; $letterFreq{ $_ } ++ for split m{}, $name; print map { qq{$_: $letterFreq{ $_ }\n} } sort { $letterFreq{ $b } <=> $letterFreq{ $a } || $a cmp $b } keys %letterFreq;

The output.

x: 3 y: 2 e: 1 q: 1 r: 1 t: 1 w: 1

I hope this is useful.

Cheers,

JohnGG