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

Re: 99 bottles of beer on the wall

From:
=?iso-8859-1?q?Andrew=20Savige?=
Date:
May 24, 2003 22:41
Subject:
Re: 99 bottles of beer on the wall
Message ID:
20030525054117.74154.qmail@web10908.mail.yahoo.com
Ronald J Kimball wrote:
> Then please consider my more recent version...  :)
>
> $n=pop||99;sub b{"$n bottle@{[$n!=1&&s=>]} of beer"}print$b=b,$w=' on
> the wall',
> ",\n$b,\nTake one down, pass it around,\n",b($n--),"$w.\n"while$n
>
> P.S.  Yes, you can save characters by using literal newlines, but
> I find that cheesy, and it makes the code difficult to execute as
> a command line.

And here is the cheesy version of Ron's more recent version, with
output matching exactly the originals of four and a half years ago:

$n=shift||99;sub b{"$n bottle@{[$n!=1&&s=>]} of beer"}
print$b=b,$w=' on the wall',
", $b!
Take one down, pass it around,
",b($n--),"$w!

"while$n

which I score at 144 strokes.
(It is debatable whether you should allow pop instead of shift for
the argument; I have stuck with shift for reasons of tradition but
am happy to be out-voted on that one).

/-\


http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.



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