develooper Front page | perl.fwp | Postings from May 2003

Re: 99 bottles of beer on the wall

From:
fun_with_perl
Date:
May 26, 2003 11:36
Subject:
Re: 99 bottles of beer on the wall
Message ID:
batmou$13i$1@post.home.lunix
In article <baqd93$1io$3@post.home.lunix>,
	fun_with_perl@ton.iguana.be (Ton Hospel) writes:
> $n=pop||99;sub b{"$n bottle"."s"x!!--$n." of beer"}print$b=b,$w=" on the wall",",\n$b,\nTake one down, pass it around,\n",b,"$w.\n"while++$n

With a little more effort by mtve and me this becomes:

sub b{[@b=(abs||n.o,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

(which also has the "no" for 0 bottles. use ~99 if you want the song to start 
with 100 bottles).



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About