in reply to Need help with an if statement

Hi,

try this approach by completing this program,

the ... is the part you write, refer to perlintro and Basic debugging checklist as your study notes.

When you're finished or when you get stuck , post what you have , ask a question

#!/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 aga +in.\n", byenoword => "No such word found.\n", wordfrequency => "...", ); ## debugging WordFrequency exit WordFrequency( \"this is in memory test file with test words", "t +est" ); 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 { ... }