Hello,
Can someone please suggest a better method than using
while (){
s/[abc]/2/gi;
# 3-8 left out for brevity
s/[wxy]/9/gi;
}
to convert a list of words into numbers based on the
phone keypad?
thanks in advance,
-- Drew Cohan
[EMAIL PROTECTED
On Jun 18, Drew Cohan said:
while (){
s/[abc]/2/gi;
# 3-8 left out for brevity
s/[wxy]/9/gi;
}
to convert a list of words into numbers based on the
phone keypad?
This is why tr/// is useful.
while () {
$_ = lc;
tr{abcdefghijklmnoprstuvwxy}
Thanks, very helpful!
-- Drew.
--- Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote:
On Jun 18, Drew Cohan said:
while (){
s/[abc]/2/gi;
# 3-8 left out for brevity
s/[wxy]/9/gi;
}
to convert a list of words into numbers based on
the
phone keypad?
This is why tr/// is
tr{abcdefghijklmnoprstuvwxy}
{222333444555666777888999};
or, for a smidgen extra legibility:
tr{abc def ghi jkl mno prs tuv wxy}
{222 333 444 555 666 777 888 999};