Question: Instructions: Your assignment is writing a Perl program called words.pl that reads in text from the diamond operator and writes the words in alphabetical order

Instructions: Your assignment is writing a Perl program called words.pl that reads in text from the diamond operator and writes the words in alphabetical 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 under- scores Along with each word, you should also write the number of times that it occurs and the line numbers in ascending order on which it was found. Since a word may or may not be capitalized, you should convert each word encountered to have lowercase letters only Consider the following input: # ! /usr/bin/perl -w use strict; # This line will print a hello world ne print "Hello world! "; exit 0 The output should be formatted as follows. Each line should first contain the word, where each word is printed in a right justified field that is as wide as the longest word encountered. Afterwards, print a colon and a blank. Next, print the number of times that the word was encountered as a four digit right justified field. Next, print " times, lines: ". Finally, print the list of line numbers in ascending order on which the word was encountered. If a word appears on a line more than once, then just print the line number once Below is the output of the program using the input above bin: exit: hello: line: perl: print: strict: this: use: usr: will: world: 1 times, lines: 1 1 times, lines: 8 2 times, lines: 5, 6 2 times, lines: 5 1 times, lines: 1 2 times, lines: 5, 6 1 times, lines: 3 1 times, lines: 5 1 times, lines: 3 1 times, lines: 1 1 times, lines: 5 2 times, lines: 5, 6 Instructions: Your assignment is writing a Perl program called words.pl that reads in text from the diamond operator and writes the words in alphabetical 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 under- scores Along with each word, you should also write the number of times that it occurs and the line numbers in ascending order on which it was found. Since a word may or may not be capitalized, you should convert each word encountered to have lowercase letters only Consider the following input: # ! /usr/bin/perl -w use strict; # This line will print a hello world ne print "Hello world! "; exit 0 The output should be formatted as follows. Each line should first contain the word, where each word is printed in a right justified field that is as wide as the longest word encountered. Afterwards, print a colon and a blank. Next, print the number of times that the word was encountered as a four digit right justified field. Next, print " times, lines: ". Finally, print the list of line numbers in ascending order on which the word was encountered. If a word appears on a line more than once, then just print the line number once Below is the output of the program using the input above bin: exit: hello: line: perl: print: strict: this: use: usr: will: world: 1 times, lines: 1 1 times, lines: 8 2 times, lines: 5, 6 2 times, lines: 5 1 times, lines: 1 2 times, lines: 5, 6 1 times, lines: 3 1 times, lines: 5 1 times, lines: 3 1 times, lines: 1 1 times, lines: 5 2 times, lines: 5, 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
