User Tools

Site Tools


cs498gpl:perl_exercises

Perl Exercises

  • Deadline: TBA
    • Use the Perl exercises dropbox on ecampus. Don't dropbox any input or output files.
    • ecampus will reject files with the .pl extension, so either rename your files to .txt or zip your .pl files and dropbox them.
  • NOTE: Unless otherwise noted, all work listed here is mandatory and counts toward your assignments grade.
  • NOTE 2: (Exercises 2-6 can be completed using regular expression search and replace or standard functions such as length or split.)
  • NOTE 3: You must insert your name, program description, course name, and semester in a comment block at the top of each program or else you will lose points.

Exercise 1 - word length occurrences

Download english.sorted.txt to your perl exercises folder. The english.sorted.txt file contains a list of words of variable length. Write perlex1.pl to find the number of occurrences of each word length in english.sorted.txt. That is, find and print the number of words in english.sorted.txt that are one character long, two characters long, three characters long and so on.

Sample output:

Word length	Occurrences

1		27
2		104
3		1038
4		3501
5		7179
6		11758
7		15892
...
...

cs498gpl/perl_exercises.txt · Last modified: by jchung

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki