use strict; use warnings; my $str = '4512872356698'; my $len = length $str; substr($str, 6, $len - 10) = 'X' x ($len - 10); print "$str\n";