hello Perlmonks, i have a phone list in a text file, the names and phone numbers are a bit jumbled up, i am wanting a script to sort them like this:
Black, Joe (333)-321-0987
Smith, Sue (333)-321-0534
Brown, Andy (333)-587-0986
Currently, they look something like this:
Black, Joe 0987
Smith, Sue 0534
Brown, Andy 587-0986
the area code on all numbers in the txt file will need to be (333) for example, and the exchange prefix is assumed to be 321 unless otherwise specified, such as the one example that shows 587 as the exchange prefix.
The names and numbers need to list in ascending alpha order by last name, no quotation marks, even columns, inserts area code as (333) unless otherwise marked, dashes between area code and exchange prefix and between line number
i found another post on here which would allow me to properly format the phone numbers, but i have no idea how i would incorporate that in a script or write a new script that would allow me to format an entire txt file and output it to another text file with the names/numbers correctly formatted. Thanks in advance for any help.
heres the other code i found:
#!/perl/bin/perl use strict; use warnings; # The assumption is that the number will always be exactly ten digits my $s = "0123456789"; print $s, "\n"; $s =~ s/^(\d{3})(\d{3})(\d{4})$/($1)$2-$3/; print $s, "\n"; __OUTPUT__ 0123456789 (012)345-6789
In reply to trying to format a list by sonikd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |