Compare two words with cmp : Compare « String « Perl






Compare two words with cmp

   

#!/usr/bin/perl

use warnings;
use strict;

my @words = split ('\s+',<>);
die "Enter two words \n" unless scalar(@words) == 2;

my $result = $words[0] cmp $words[1];
print $result;

   
    
    
  








Related examples in the same category

1.Comparing Strings
2.String comperison operator: cmp
3.String comperison operator: equal
4.String comperison operator: gt (greater than)
5.String comperison operator: lt (less than)
6.The correct use of three of the operators: eq, it, and gt.
7.A very simple password checker.
8.Check password