my $line = 'abbc'; $line =~ s/(.)/X$1X/g; say $line; --output:-- XaXXbXXbXXcX