If you split on "nothing", // this yields each individual character in that string. Simple way to do replacement would be a "look-up" table to see if something should be substituted for that character. Some slight efficiency could be gained with "if..else", but below demonstrates the main point...Adapt as you will...key thing is the "split" to get each character in line, then use hash to look up substitute number.
#!/usr/bin/perl -w
use strict;
my %xlate = ('A' => 1000,
'B' => 2000,
'X' => 9999,
);
while (<DATA>)
{
chomp;
foreach my $ltr (my @ltrs = split(//,$_))
{
print "$xlate{$ltr} " if $xlate{$ltr};
print "$ltr " if !$xlate{$ltr};
}
print "\n";
}
__END__
Prints:
1000 1000 2000 2000 C C
1000 C 2000 9999 1000
__DATA__
AABBCC
ACBXA