in reply to Counting to add space to a string

another way probably

if (/^[[:allnum:]]{1,13}$/){ =~ s/^([[:allnum:]]{1,13})$/$1.'X'/ }

to be used inside a loop

I need to include a "X" after the initial letters.

You could print the X in any position you want. i.e, after the first letter

if (/^[[:allnum:]]{1,13}$/){ =~ s/^([[:allnum:]]{1})([[:allnum:]]{1,12})$/$s1 .'X'. $2/ }