programming-examples/perl/Statement/Plural output with if statement.pl
2019-11-15 12:59:38 +01:00

19 lines
291 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
my @words = split ('\s+', <>);
my $count = scalar (@words);
print "There ";
if ($count == 1) {
print "is";
} else {
print "are";
}
print " $count word";
unless ($count == 1) {
print "s";
}
print " in the text \n";