title: perl - comparing two strings, one a subroutine parameter
body: <p>I am trying to work through what should be some simple exercises and with this one I am having problem comparing two strings (one in an array, and the other as supplied to a function). In particular, the line:</p>
  
  <pre><code> if ($el eq $iName) 
  </code></pre>
  
  <p>doesn't return 1 even when the two strings are equal. </p>
  
  <p>I have put some debug lines above that piece of code to see what is the value of that boolean and it seems as though it is undef.</p>
  
  <pre><code>#!/usr/bin/perl -w
  
  use v5.14.0;
  
  
  sub greet {
      #early example - no hashes, 
  
      #if first ever name print the name, 
      #if not first and not previously seen, print previous names, 
      #if same name as one previous, acknowledge this and print previous names
  
      my $iName = $_[0];
      state @seen_names;
  
      if (!@seen_names) {
          print "Hello $iName\n";
          push @seen_names, "$iName ";
      } else {
          my $push_name = 0;
          foreach my $el (@seen_names) {
  
  #------------------------DEBUG-----------
          print "equal? ", ("$el" eq "$iName"), "----\n"; #debug - the boolean looks undef
          print "equal? ", ("$el" eq undef), "----\n"; #debug
          print "equal? ", ("a" eq "a"), "----\n"; #debug
  #------------------------DEBUG-----------
  
              if ($el eq $iName) { #debug - do not get into this if
                  #FIXME prints *all* names, including this one.
                  print "hello again $iName, all visitors so far: " , @seen_names, "\n";
              } else {
                  print "hello $iName, all visitors so far: @seen_names.\n";
                  $push_name = 1;
              }
          }
          if ($push_name) {
              push @seen_names, "$iName ";
          }
      }
  }
  
  &amp;greet ("Greg");
  &amp;greet ("Greg");
  #&amp;greet ("Bob");
  #&amp;greet ("James");
  #&amp;greet ("Jill");
  </code></pre>
  
  <p>Where am I going wrong?</p>