COP4342 - 2006 FallAssignment 5Word IndexObjectives: Learn how to use explicit and automatic memory variables,the exists function, the substitution command, the string concatenationoperator, pattern matching, and more experience with hashes, the sort op-erator, and formatted output.Instructions: Your assignment is write to a Perl program called words.plthat reads in text from the diamond operator and writes the words in alpha-betical order to standard output.Each word should consist of two or more characters, start with a letter,and the remaining characters consist of letters, digits, and underscores. Alongwith each word, you should also write the number of times that it occurs andthe line numbers in ascending order on which it was found. Since a wordmay or may not be capitalized, you should convert e ach word encounteredto have lowercase letters only.Consider the following input:#!/usr/bin/perl -wuse strict;# This line will print a hello world line.print "Hello world!\n";exit 0;The output should be formatted as follows: Each line should first containthe word, where each word is printed in a right-justified field that is as wideas the longest word encountered (and not zero-filled, unlike assignment 4.)Afterwards, print a colon and a blank. Next, print the number of timesthat the word was encountered as a four digit right-justified field. Next, print” times, lines: ”. Finally, print the list of line numbers in ascending order1on which the word was encountered. If a word appears on a line more thanonce, then just print the line number once.Below is the output of the program using the input above.bin: 1 times, lines: 1exit: 1 times, lines: 8hello: 2 times, lines: 5, 6line: 2 times, lines: 5perl: 1 times, lines: 1print: 2 times, lines: 5, 6strict: 1 times, lines: 3this: 1 times, lines: 5use: 1 times, lines: 3usr: 1 times, lines: 1will: 1 times, lines: 5world: 2 times, lines: 5, 6Submission: Submit the words.pl Perl program as an attachment inan e-mail message to [email protected] before the beginning of class onWednesday, October
View Full Document