99 bottles of beer: Difference between revisions

Content added Content deleted
(added Chapel)
Line 3,426: Line 3,426:
}</lang>
}</lang>


Correct grammar and nice output spacing way:
Correct grammar and nice spacing in modern perl:
<lang perl>use 5.10.0;
<lang perl>my $num = 99; #starting bottle count

for (0..98) { #times going through
$num = 99;
my $s = "s" unless ($num == 1); #grammar
while ($num > 0) {
print "$num bottle$s of beer on the wall\n";
my $s = "s" unless ($num == 1);
print "$num bottle$s of beer\n";
say "$num bottle$s of beer on the wall, $num bottle$s of beer";
print "Take one down, pass it around\n";
$num--; #bottle count down
$num--;
my $s = "s" unless ($num == 1); #grammar
my $s = "s" unless ($num == 1);
print "$num bottle$s of beer on the wall\n";
$num = "No more" if ($num == 0);
say "Take one down, pass it around, $num bottle$s of beer on the wall\n"
if ($num != 0) { #useless spacing trick
}
print "\n";

}
say "No more bottles of beer on the wall, no more bottles of beer.";
}</lang>
say "Go to the store and buy some more, 99 bottles of beer on the wall.";</lang>


=={{header|Perl 6}}==
=={{header|Perl 6}}==