#!/usr/bin/perl -w use strict; print "Welcome to the word frequency calculator.\n"; print "This program prompts the user for a file to open, \n"; print "then it prompts for a word to search for in that file,\n"; print "finally the frequency of the word is displayed.\n"; print " \n"; print "Please enter the name of the file to search:"; chomp (my $filename = ); if (not -e $filename){ print "No such file exists. Exiting program. Please try again.\n"; exit; } print "Enter a word to search for:"; chomp (my $word = ); if (not -e $word){ print "No such word found.\n"; exit; } print "Frequency of word: " . grep $word eq $_, split /\W+/i, do { local (@ARGV, $/)= $filename; <> }; exit;