programming-examples/perl/String/Compare two words with cmp.pl

13 lines
202 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/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;