Jump to content

99 bottles of beer: Difference between revisions

(added Chapel)
Line 3,426:
}</lang>
 
Correct grammar and nice output spacing wayin 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); #grammar
print "$num bottle$s of beer\n";
printsay "$num bottle$s of beer on the wall\n, $num bottle$s of beer";
print "Take one down, pass it around\n";
$num--; #bottle count down
my $s = "s" unless ($num == 1); #grammar
print "$num bottle$s= of"No beermore" onif the($num wall\n"== 0);
printsay "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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.