Perl Programming/Simple examples 1

This script counts the number of occurences of each letter in a file:

If you executed this program on a file containing the sentence "The quick, brown fox jumps over the lazy dog.", you would see this as output:

a appeared once. b appeared once. c appeared once. d appeared once. e appeared 3 times. f appeared once. g appeared once. h appeared 2 times. i appeared once. j appeared once. k appeared once. l appeared once. m appeared once. n appeared once. o appeared 4 times. p appeared once. q appeared once. r appeared 2 times. s appeared once. t appeared 2 times. u appeared 2 times. v appeared once. w appeared once. x appeared once. y appeared once. z appeared once.

I have added a bit to this code to enable the user to create a report of the data if they wish: