1. What is your name? 2. Please list your address and home phone number. 3. What is your mother's maiden name (name before marriage)? 4. Name your four favorite bands or artists: #### use strict; use Data::Dumper; my $file = "questions.lst"; my $answer = <) { s/^\s+//g; if (/^\d/) { chomp; push(@questions, $_); } } return @questions; } #### $VAR1 = '1. What is your name?'; $VAR2 = '2. Please list your address and home phone number.'; $VAR3 = '3. What is your mother\'s maiden name (name before marriage)?'; $VAR4 = '4. Name your four favorite bands or artists:'; ---------- BEGIN TEST ---------- TEST: $answer matched 1. What is your name? TEST: $answer matched 2. Please list your address and home phone number. TEST: $answer matched 3. What is your mother's maiden name (name before marriage)? TEST: $answer matched 4. Name your four favorite bands or artists: ---------- END TEST ---------- Checking $questions[0] and $questions[1] Matching element 0 Did NOT match 1. What is your name? Matched 2. Please list your address and home phone number. ----------------------------- Checking $questions[1] and $questions[2] Matching element 1 Did NOT match 2. Please list your address and home phone number. Matched 3. What is your mother's maiden name (name before marriage)? ----------------------------- Checking $questions[2] and $questions[3] Matching element 2 Did NOT match 3. What is your mother's maiden name (name before marriage)? Matched 4. Name your four favorite bands or artists: ----------------------------- Checking $questions[3] and $questions[4] Matching element 3 Did NOT match 4. Name your four favorite bands or artists: ----------------------------- #### # Loop trying to match current question and next question my $i; for($i = 0; $i < scalar(@questions); $i++) {  my $answer2 = $answer; # !!!NEW!!!  my $j = $i + 1; # $j is the next element of the array  print qq/Checking \$questions[$i] and \$questions[$j] \n/;  print qq/Matching element $i\n/;  if ($answer2 =~ m/$questions[$i]/g) {   print qq(Matched $questions[$i]\n);  } else {   print qq(Did NOT match $questions[$i]\n);   }    if ($questions[$j]) {   if ($answer2 =~ m/\Q$questions[$j]\E/g) {    print qq(Matched $questions[$j]\n);   } else {    print qq(Did NOT match $questions[$j]\n);    }  }    print qq(-----------------------------\n); # Dividing line } #### $VAR1 = '1. What is your name?'; $VAR2 = '2. Please list your address and home phone number.'; $VAR3 = '3. What is your mother\'s maiden name (name before marriage)?'; $VAR4 = '4. Name your four favorite bands or artists:'; ---------- BEGIN TEST ---------- TEST: $answer matched 1. What is your name? TEST: $answer matched 2. Please list your address and home phone number. TEST: $answer matched 3. What is your mother's maiden name (name before marriage)? TEST: $answer matched 4. Name your four favorite bands or artists: ---------- END TEST ---------- Checking $questions[0] and $questions[1] Matching element 0 Matched 1. What is your name? Matched 2. Please list your address and home phone number. ----------------------------- Checking $questions[1] and $questions[2] Matching element 1 Matched 2. Please list your address and home phone number. Matched 3. What is your mother's maiden name (name before marriage)? ----------------------------- Checking $questions[2] and $questions[3] Matching element 2 Matched 3. What is your mother's maiden name (name before marriage)? Matched 4. Name your four favorite bands or artists: ----------------------------- Checking $questions[3] and $questions[4] Matching element 3 Matched 4. Name your four favorite bands or artists: -----------------------------