#!/usr/bin/perl use strict; use warnings; # 927370 - OP seeks to insert 'X' enough times to pad to len=14 AFTER the LETTERS use 5.012; # NB: First account in this array needs more than one 'X'tension... my @account = qw/CAL2345-06 CALI123456-09 FLOR1234567-01/; for my $account(@account) { my $total_count = 0; while ($account =~ m/./g) { $total_count++ ; } say "At ln 15, |$account| has $total_count characters"; while ($total_count < 14) { substr($account, 4, 0) = 'X'; $total_count++; } continue { # loop till $total_count == 14 ! say "At ln 21, |$account| has $total_count characters"; } next; } #### C:\>927370.pl At ln 15, |CAL2345-06| has 10 characters At ln 21, |CAL2X345-06| has 11 characters