Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: 99 Bottles Of Beer (can't we do better)

by screamingeagle (Curate)
on Feb 20, 2002 at 05:25 UTC ( #146505=note: print w/ replies, xml ) Need Help??


in reply to 99 Bottles Of Beer (can't we do better)

well,if its golf we're playing , then a couple of minor changes saves a few lines :

$nBottles = ($ARGV[0] > 0) ? $ARGV[0] :100; foreach (reverse(1 .. $nBottles)) { $s = ($_ == (1 || 2)) ? "" : "s"; print "\n$_ bottle$s of beer on the wall,\n$_ bottle$s of beer,\nTake +one down, pass it around,\n" , ($_ - 1)," bottle",(($_ - 1) == 1) ? " + " : "s "," of beer on the wall\n"; } print "\n*burp*\n";
Second Update Reduced by a couple more lines :
$nBottles = ($ARGV[0] > 0) ? $ARGV[0] :100; foreach (reverse(1 .. $nBottles)) { print "\n$_ bottle",($_ == (1 || 2)) ? "" : "s"," of beer on the wall, +\n$_ bottle",($_ == (1 || 2)) ? "" : "s"," of beer,\nTake one down, p +ass it around,\n" , ($_ - 1)," bottle",(($_ - 1) == 1) ? " " : "s "," + of beer on the wall\n";}print "\n*burp*\n";
Update: fixed a typo (thanks to particle)


Comment on Re: 99 Bottles Of Beer (can't we do better)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://146505]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2015-08-01 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls