Cheap and dirty, cheezy, kindergarteny, but it does what you want:
use strict;
use warnings;
my $phnum = '847-VICTORY';
print "before: \"$phnum\"\n";
$phnum =~ s/[ABC]/2/ig;
$phnum =~ s/[DEF]/3/ig;
$phnum =~ s/[GHI]/4/ig;
$phnum =~ s/[JKL]/5/ig;
$phnum =~ s/[MNO]/6/ig;
$phnum =~ s/[PQRS]/7/ig;
$phnum =~ s/[TUV]/8/ig;
$phnum =~ s/[WXYZ]/9/ig;
# add hyphen
$phnum =~ s/-(\d\d\d)(\d\d\d\d)/-$1-$2/;
print "after: \"$phnum\"\n";
before: "847-VICTORY"
after: "847-842-8679"
Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
224-542-5150
I think you should profit from the mistakes of others. You don't live long
enough to make them all yourself. -- Lowell Ferguson
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs