replace a string in a perl array.

hello experts. does anyone know how I can replace strings in my array into a different string? example @array = ("A H")
I would like to replace the a with ace and h with hearts. thanks.
LVL 2
micromarchAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
#anticipating another question:
my %tr=(
H => "hearts",
S => "spades",
D => "diamonds",
C => "clubs",
A => "ace",
2 => "two",
3 => "three",
4 => "four",
10 => "ten",
J => "jack",
K => "king",
Q => "queen",
);
s/(\d+|\w)/$tr{uc $1}/g for @array;
0
 
ozoCommented:
s/A/ace/,s/H/hearts/ for @array;
0
 
HonorGodSoftware EngineerCommented:
ozo, you are something else...  no wonder you have so many answered questions & points. :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.