#!/usr/bin/perl -w use strict; print "This program will say 'Hello' to Jim or Fred.\n"; my $myPattern = "^(Jim|Fred)\$"; # The pattern matches only 'Jim' or 'Fred'. Nothing else is allowed. print "Enter your first name here: "; my $myTestString = ; chomp ($myTestString); if ($myTestString =~ m/$myPattern/x) { print "Hello $myTestString. How are you today?"; } else { print "Sorry I don't know you!"; }