Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: 99 bottles, 2 lines

by o(o_o)o (Scribe)
on Jan 08, 2002 at 06:46 UTC ( #137039=note: print w/ replies, xml ) Need Help??


in reply to Re: 99 bottles, 2 lines
in thread 99 bottles, 2 lines

Hey, i'm new to posting on here, and am trying to work on loadsa things to get myself better at programming in perl... and this one i thought looked cool... so i gave it a try, and nicked a bit of code from chipmunk's code and made my own... it's only 1 line... but one hell of a line... only 1 semicolon in sight! :-) i thought the horrible lot of numbers i put in the qw() could be done a better way, but i was trying to get it done in just the one line, so i gave up trying to think of a way to do it. but this is what i have.

map { print "$_ bottle@{[$_!=1&&s=>]} of beer on the wall, $_ bottle@{ +[$_!=1&&s=>]} of beer. Take 1 down, pass it around, ".($_-1)." bottl +e@{[$_-1!=1&&s=>]} of beer on the wall.\n" } reverse 1..99;
Update: the long line has been decreased thanks to blakem! now it's one line that actually looks pretty sweet! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
i would slit my wrists for you


Comment on Re: 99 bottles, 2 lines
Download Code
Re: Re: 99 bottles, 2 lines
by blakem (Monsignor) on Jan 08, 2002 at 06:58 UTC
    How about:
    my @a = reverse 1..99;
    you can probably just inline reverse 1..99 since I don't see you actually using @a anywhere....

    -Blake

      yeah! cool... thanks! i'm new to posting and am well happy someone gave me a helpfull reply! :-) thanks for makin the line smaller. i wont post the complete code coz people can just read this post to get it. ;) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      i would slit my wrists for you

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-08-23 10:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls