Perl Programming Use the splice function to replace the current phone number wit
ID: 3673183 • Letter: P
Question
Perl Programming
Use the splice function to replace the current phone number with the new phone number, or use any of the other built-in array functions to produce output that resembles the following:
Who are you searching for?
Karen What is the new phone number for Karen? 530-222-1255
Karen’s phone number is currently 284-758-2857.
Here is the line showing the new phone number:
Karen Evich:530-222-1255:23 Edgecliff Place, Lincoln, NB 92086:7/25/53:85100
Karen was found in the array three times.
All design base on data provided.
__DATA__
John DeLoach:408-253-3122:123 Park St., San Jose, CA 04086:7/25/53:85100
Karen Evich:284-758-2857:23 Edgecliff Place, Lincoln, NB 92086:7/25/53:85100
Karen Evich:284-758-2867:23 Edgecliff Place, Lincoln, NB 92743:11/3/35:58200
Karen Evich:284-758-2867:23 Edgecliff Place, Lincoln, NB 92743:11/3/35:58200
Fred Fardbarkle:674-843-1385:20 Parak Lane, DeLuth, MN 23850:4/12/23:780900
Explanation / Answer
#!/usr/bin/perl
@phone number = (284-758-2857,408-253-3122,674-843-1385);
@names = ("Karen Evich", "John DeLoach", "Fred Fardbarkle");
@address = ("123 Park St., San Jose, CA 04086:7/25/53:85100","23 Edgecliff Place, Lincoln, NB 92086:7/25/53:85100","20 Parak Lane, DeLuth, MN")
print "$phone number[0] = $phone number[0] ";
print "$phone number[1] = $phone number[1] ";
print "$phone number[2] = $phone number[2] ";
print "$names[0] = $names[0] ";
print "$names[1] = $names[1] ";
print "$names[2] = $names[2] ";
print "$address[0] = $address[0] ";
print "$address[1] = $address[1] ";
print "$address[2] = $address[2] ";
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.