Mega Code Archive

 
Categories / Perl / Statement
 

Plural output with if statement

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