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

Re: 99 bottles of beer on the wall

Thread Previous | Thread Next
Zed Lopez
May 26, 2003 11:40
Re: 99 bottles of beer on the wall
Message ID:
My solution was (added the 'pop||' to match the constraint others are
accepting of taking a parameter):

@h=map"$_ bottles of beer",0..pop||99;$h[1]=~s/s//;$o=" on the wall";$a=pop@h,print"$a$o,\n$a,\nTake one down, pass it around,\n$h[$#h]$o.\n"while$#h

149 characters, 145 with literal newlines.

Don't see a way to beat Ron's subroutine approach with the
preinitialized array approach.

zed at-sign apricot dot com            
Zed Lopez PO Box 12546 Berkeley CA 94712

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About