programming-examples/perl/String/The correct use of three of the operators eq, it, and gt.pl
2019-11-15 12:59:38 +01:00

27 lines
605 B
Perl

#!/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";
}
}