$A = ( scalar join '', map { $a = $_ + 48; $a = pack('c',$a); # converts ord to chr without using 'chr' $a =~ s/(b|2)/$1-/; # appends a '-' if it's a 'b' or a '2' $a } ( 50, 74, 49, 2, 9, 0, 1 ) );