#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11132285 use warnings; my @email = ( 'someone@example.co.uk', 'andrew.test@some.company.co.uk', 'jo@abc.com', ); foreach my $em(@email) { print "$em - "; $em =~ s/\w{2}\K(\w*)/ $1 =~ tr!!.!cr /ge; print "$em\n"; } #### someone@example.co.uk - so.....@ex......co.uk andrew.test@some.company.co.uk - an.....te..@so...co......co.uk jo@abc.com - jo@ab..co.