The correct use of three of the operators: eq, it, and gt. : Compare « String « Perl






The correct use of three of the operators: eq, it, and gt.

   

    #!/usr/local/bin/perl -w

    # Do this forever.
    for (;;)
    {
       print "Enter a word: ";
       my $word1 = <STDIN>; chomp $word1;
       print "Enter another word: ";
       my $word2 = <STDIN>; chomp $word2;

       if ($word1 eq $word2)
       {
          print "The two phrases are equivalent.\n";
       }
       elsif ($word1 lt $word2)
       {
          print "<$word1> is alphabetically less than <$word2>\n";
       }
       elsif ($word1 gt $word2)
       {
          print "<$word1> is alphabetically greater than <$word2>\n";
       }
    }

   
    
    
  








Related examples in the same category

1.Compare two words with cmp
2.Comparing Strings
3.String comperison operator: cmp
4.String comperison operator: equal
5.String comperison operator: gt (greater than)
6.String comperison operator: lt (less than)
7.A very simple password checker.
8.Check password