A few notes:
- "shift(@_)" can be written simply as "shift"
- The subroutine should return a string, instead of
setting a global variable. It's a good practice to
get into, especially when you start messing with packages.
- A return also allows the sub to be stuck directly into
the program without using a variable (see the chad example below)
- The ternary operator is cool. :)
my $plur = &pluralize($items);
print "$items item$plur listed";
print "I counted $chads vote", &pluralize($chads),"!\n";
sub pluralize($) {
return shift==1 ? "" : "s";
}