Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Perl

(standard version)

Date:04/20/05
Author:Jim Menard
URL:n/a
Comments:2
Info:n/a
Score: (3.02 in 175 votes)
#!/usr/bin/perl
# Jim Menard     jimm@{bbn,io}.com     (617) 873-4326    http://www.io.com/~jimm/
$nBottles = $ARGV[0];
$nBottles = 100 if $nBottles eq '' || $nBottles < 0;

foreach (reverse(1 .. $nBottles)) {
    $s = ($_ == 1) ? "" : "s";
    $oneLessS = ($_ == 2) ? "" : "s";
    print "\n$_ bottle$s of beer on the wall,\n";
    print "$_ bottle$s of beer,\n";
    print "Take one down, pass it around,\n";
    print $_ - 1, " bottle$oneLessS of beer on the wall\n";
}
print "\n*burp*\n";

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
bottled by Acme::EyeDropsAndrew Savige06/04/0576
for signatureRandolph Chung, Joey Hess04/20/050
bottled versionChristopher J. Carlson05/17/057
Lingua::EN::InflectMarty Pauley04/20/051
minimal versionMark Sheppard06/01/051
object-oriented versionScott Bryce05/15/051
polyglotJeff Connelly04/20/050
BigIntAnonymous04/20/050

Comments

>>  Lat1n0S said on 02/21/06 00:52:10

Lat1n0S Kill himself!

>>  Christopher E. Stith said on 08/20/08 18:30:15

Christopher E. Stith I was disappointed that no new examples in Perl are to be accepted. There are some neat and clever versions there, but none showcasing particularly mainstream coding practices. Something more representative of how the Perl community suggests code is written might be desirable.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: