#!/usr/bin/perl
#w3.5a.pl foreach()  

@people = (Jim, Floyd, Fred, Jane, Marta, Jill, Sam, Joe, Alice, Andrea);

print("Please enter your name: ");
chomp($name = <STDIN>);

if ($name eq "Marvin") {die "No Marvins allowed.  $!";}

for (@people){				#"for" equals "foreach"
#  print ("Check $_\n");		#DEBUG
   if ($_ eq $name){
      print("Yes, $_, you can use our computer.\n");
      $success = 1;
      last;
   }					#End if block
}					#End for block

if (!$success){
   print("Sorry, $name, you are not on my list.\n");   
}

__END__

