my %convert = ( A => 1000, B => 2000, C => 3000, ); my @data = map $convert{ $_ }, $input =~ /[ABC]/g;