Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: 99 bottles of beer on the wall

by mojotoad (Monsignor)
on Apr 02, 2004 at 23:24 UTC ( #342181=note: print w/replies, xml ) Need Help??


in reply to 99 bottles of beer on the wall

You'll probably be interested in node 99 Bottles Of Beer (can't we do better).

Just cause I'm chirpy today, I'll reprise my not-very-terse solution:

#!/usr/bin/perl $bc = abs(shift || 100); $p_sub = sub { 'Take ' . (shift == 1 ? 'it' : 'one') . " down, pass it around,\n" }; $b_sub = sub { 'bottle' . (shift != 1 ? 's' : '') }; $c_sub = sub { $_ = shift||'No'; "$_ " . &$b_sub($_) . ' of beer' }; $w_sub = sub { &$c_sub(shift) . " on the wall"; }; $sub = sub { $_ = shift; print &$w_sub($_), ",\n", &$c_sub($_), ",\n", &$p_sub($_), &$w_sub(--$_), ".\n\n" }; map(&$sub($_), reverse(1 .. $bc)); print "burp!\n";

Matt

Replies are listed 'Best First'.
Re: Re: 99 bottles of beer on the wall
by bassplayer (Monsignor) on Apr 09, 2004 at 13:46 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://342181]
help
Chatterbox?
[finddata]: How do i perform multiple line substitution into single line for same variable using perl

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-02-24 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (352 votes). Check out past polls.