in reply to formatted phone number from variable
A regular expression with substitution is one way. Some extras included:
my $phone = '1234567890'; # convert alpha mnemonics $phone =~ tr/A-PR-Z/222333444555666777888999/; $phone =~ tr/a-pr-z/222333444555666777888999/; # get rid of any nondigits $phone =~ s/\D//g; # format $phone =~ s/^(\d{3})(\d{3})(\d{4})$/{$1) $2-$3/; $phone =~ s/^(\d{3})(\d{4})$/$1-$2/; # no AC print $phone, $/;
(Added) 'perldoc perlre' is the primary reference. It should be installed with your perl.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: formatted phone number from variable
by powerhouse (Friar) on May 22, 2003 at 06:26 UTC | |
by PodMaster (Abbot) on May 22, 2003 at 06:37 UTC | |
by Aragorn (Curate) on May 22, 2003 at 07:07 UTC | |
|
Re: Re: formatted phone number from variable
by Skeeve (Parson) on May 22, 2003 at 07:56 UTC |