#!/usr/bin/perl -- use strict; use warnings; our %messages = ( welcome => " Welcome... ", promptfile => "Please enter the name of the file to search:", promptword => "Enter a word to search for:", byenofile => "No such file exists. Exiting program. Please try again.\n", byenoword => "No such word found.\n", wordfrequency => "...", ); ## debugging WordFrequency exit WordFrequency( \"this is in memory test file with test words", "test" ); my $file = Prompt( $messages{welcome}.$messages{promptfile} ); my $word = Prompt( $messages{promptword} ); WordFrequency( $file, $word ); exit; sub WordFrequency { my( $file , $word ) = @_; open my($fh), '<', $file or die $messages{byenofile}; my $freq = 0; ...; if( $freq ){ print $messages{wordfrequency}, $freq, "\n"; } else { print $messages{byenoword}; } return $freq; } sub Prompt { ... }