Use perl programming to write: Ask the user for the name of a person to find. Us
ID: 3673585 • Letter: U
Question
Use perl programming to write:
Ask the user for the name of a person to find.
Use the built-in grep function to find the elements of the array that contain the person and number of times that person is found in the array.
The search will ignore case.
Use this array to use the grep function
@arrayList = (
"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
Consider the following program: #!/usr/bin/perl #CREATE AN ARRAY @perl_array1 = qw(Perl Programming Tutorial ); @perl_array2 = ("Perl ", "Programing ", "Tutorial", " "); @perl_array3 = (1 .. 3); $perl_array4[0] = "Perl "; $perl_array4[1] = "Programming "; $perl_array4[2] = "Tutorial"; $perl_array4[50] = " "; #ADD ELEMENTS TO AN ARRAY $perl_array1[3] = " "; #PRINT ARRAY print @perl_array1; print @perl_array2; print @perl_array3; print $perl_array1[3]; print @perl_array4; # What index has a last element of an array print "Last element of perl_array4 has index: " . $#perl_array4 ." ";
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.