Do you know where your variables are? PerlMonks

### Drunk on golf: 99 Bottles of Beer

by eyepopslikeamosquito (Chancellor)
 on May 08, 2011 at 12:41 UTC Need Help??

```10 REM BASIC Version of 99 Bottles of beer
20 FOR X=100 TO 1 STEP -1
...
40 PRINT "Take one down and pass it around,"
50 PRINT X-1;"bottle(s) of beer on the wall"
60 NEXT
```
```use Lingua::EN::Inflect 'inflect';
\$n=shift||99;
...
Take one down, pass it around,
NO(bottle of beer,@{[--\$n]}) on the wall.
BURP
```
```sub
b{[@b=(abs||No,bottle."s"x!!++\$_,of,beer),on,the,wall]}print
"@{+b},\n@b,\nTake one down, pass it around,\n@{+b}.\n"
for-pop||-99..-1
```
```99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
...

1 bottle of beer on the wall, 1 bottle of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
```
```sub b{[@b=(abs||99,bottle."s"x!!++\$_,of,beer),on,the,wall]}print"@{+b}
+, @b.
",\$_?"Take one down and pass it around":"Go to the store and buy some
+more",", @{+b}.

"for-99..-1
```
```sub b{@b=(-\$_++||99,bottl.(\$_?es:e),of,beer);"@b on the wall"}print+b,
+", @b.
",\$_?"Take one down and pass it around, ":"Go to the store and buy som
+e more, ",b,".

"for-99..-1
```
```@{sub b{[@b=(abs||No,bottle.'s'x!!++\$_,of,beer),on,the,wall]}b}
```
```print"@{sub b{[@y=(\$n||=99,bottle.'s'x1!~\$n,of,beer),on,the,wall]}b},
+@y.
\$_, @{b--\$n}.

"for("Take one down and pass it around")x98,"Go to the store and buy s
+ome more"
```
```n=99
z=lambda:`n or 99`+" bottle"+"s of beer on the wall"[n==1:]
while n:y=z();n-=1;print"%s, %s.\n"*2%(y,y[:-12],n and"Take one down a
+nd pass it around"or"Go to the store and buy some more",z())
```
```def z
"#{N<1?99:N} bottle#{'s'if N!=1} of beer"end
(N=99).times{puts"%s, %s.
"*2%[z+w=" on the wall",z,1>(N-=1)?"Go to the store and buy some more"
+:"Take one down and pass it around",z+w],""}
```
```z+w=" on the wall"
```
```99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
...

1 bottle of beer on the wall, 1 bottle of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
```
```99 bottles of beer on the wall, 99 bottles of beer.
-----------------------------------------------------------------
...
1 bottle of beer on the wall, 1 bottle of beer.
-----------------------------------------------------------------
Go to the store and buy some more, 99 bottles of beer on the wall.
```
```Go to the store and buy some more, 99 bottles of beer on the wall.

...
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
```
```join("Take one down and pass it around",map{@c=(@b=(99-\$_,bottle.'s'x!
+/98/,of,beer),on,the,wall);", @c.

...
"}0..98)=~/

/;print\$'."Go to the store and buy some more\$`"
```
```somearray.join("string")
```
```somearray*"string"
```
```"Go to the store and buy some more"+(-99..-1).map{|n|", #{c="#{b=-n,"
+bottle"+"s of beer"[1/-n,9]} on the wall"}.

...
"}*"Take one down and pass it around"=~/

/;puts\$'+\$`
```
```"Go to the store and buy some more"+(-99..-1).map{|n|", #{b=-n," bottl
+es"[0,6-n]+" of beer"," on the wall"}.

...
"%b}*"Take one down and pass it around"=~/

/;puts\$'+\$`
```
```r="Take one down and pass it around".join(", %s.\n\n"%c+c+", %s.\n"%c[
+:-12]for c in[`99-z`+" bottle"+"s of beer on the wall"[z/98:]for z in
+ range(99)])
print r[35:]+"Go to the store and buy some more"+r[:34]
```
```n=99
y="Go to the store and buy some more"
while n:c=`n`+" bottle"+"s of beer on the wall"[1/n:];y+=", %s.\n\n"%c
++c+", %s.\nTake one down and pass it around"%c[:-12];n-=1
print y[68:-32]+y[:66]
```
```c=198
while c:y=`c/2or 99`+" bottle"+"s of beer on the wall"[3/c%3:];print[y
+,"Take one down and pass it around","Go to the store and buy some mor
+e"][1/c+c%2]+",",[y[:-12]+".",y+".\n"][c%2];c-=1
```
```n=198
loop{\$><<[y=[n/2%-99+99," bottle"+"s of beer"[3/n%3,9]," on the wall"]
+,"Take one down and pass it around","Go to the store and buy some mor
+e"][j=1/n+1&~n-=1]<<", #{y[0,2+j]}.
"+\$/*j}
```
```bottle."s"x!!++\$_,of,beer        # Perl
bottl.(\$_?es:e),of,beer          # Perl
...
" bottles"[0,6-n]+" of beer"     # Ruby
"bottle"+"s of beer"[3/n%3,9]    # Ruby
"bottle"+"s of beer"[1/n:]       # Python
```
```"bottle\$x of beer"
```
```@c=(@b=(++\$n,bottle.\$&,of,beer),on,the,wall),s/^/Take one down and pas
+s it around, @c.

...
/,/s/for(\$_)x99;/,.*

/;print\$'."Go to the store and buy some more\$&"
```
```s/./\$& \$&/gfor(\$_="-
")x pop;print
```
```/s/until@c=(@b=(++\$n,bottle.\$&,of,beer),on,the,wall),s/^/Take one down
+ and pass it around, @c.

...
/,/, 99.*

/;print\$'."Go to the store and buy some more\$&"
```
```/s/until@c=(\$b=++\$n." bottle\$& of beer",on,the,wall),s/^/Take one down
+ and pass it around, @c.

...
/,/, 99.*

/;print\$'."Go to the store and buy some more\$&"
```
```/s/until@c=(++\$n." bottle\$& of beer",on,the,wall),s/^/Take one down an
+d pass it around, @c.

...
/,/99.*

/;print\$'."Go to the store and buy some more, \$&"
```
```1.upto(99){|n|~/s/;\$_="Take one down and pass it around, #{c="#{b=n,"
+bottle#\$& of beer"} on the wall"}.

...
~/,.*

/;puts\$'+"Go to the store and buy some more"+\$&
```
```n=0
~/s/ until/, 99.*
...

#{c}, #{b}.
#\$_";puts\$'+"Go to the store and buy some more"+\$&
```
```b=[99," bottles of beer"," on the wall"]
print "%s%s\n"%b
```
```99 bottles of beer
```
```TypeError: not enough arguments for format string
```
```@b=(99," bottles of beer"," on the wall");
printf "%s%s\n",@b;
```
```b=[99," bottles of beer"," on the wall"]
print "%s%s\n"%tuple(b)
```
```TypeError: not all arguments converted during string formatting
```
```b=[99," bottles of beer"," on the wall"]
print "%s%s%s\n"%tuple(b)
```
```99 bottles of beer on the wall
```
```1.upto(99){|n|~/s/;\$_="Take one down and pass it around, #{c=n," bottl
+e#\$& of beer"," on the wall"}.

...
~/,.*

/;puts\$'+"Go to the store and buy some more"+\$&
```
```  1st  162  rhebus                             Perl
2nd  162  eyepopslikeamosquito               Perl
...
8th  171  flagitious                         Perl
9th  171  o0lit3                             Perl
10th  171  gorash                             Perl
```
```  1st  162  rhebus
2nd  162  eyepopslikeamosquito
...
65th  195  Jasper
89th  204  chargrill
98th  209  yanick
```
```  1st  173  flagitious
2nd  176  eyepopslikeamosquito
...
18th  186  carldr
19th  186  pace_t_zulu
```
```  1st  182  hallvabo
2nd  183  logan
...
18th  199  max
19th  200  Dilb
20th  200  yonilevy
```
```  1st 172  ToastyX
2nd 173  eyepopslikeamosquito
...
18th 200  phoe
19th 201  underdonges
20th 203  Theory
```

Create A New User
Node Status?
node history
Node Type: perlmeditation [id://903641]
Approved by ww
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2018-01-24 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How did you see in the new year?

Results (256 votes). Check out past polls.

Notices?