Monks - In part inspired by the previous 'Perl songs' discussion 604738 I noticed quite a few song titles lend themselves well to Perlification. This brought to mind a possible new diversion for the Monastery: write a script which both represents AND generates a clue to a song title.

Some suggested basic 'rules': (1) Must work with use strict and use warnings (2) The code itself must 'act out' the song title (3) The OUTPUT of the script must also serve as a clue to the song title.

And three examples from the very excellent Smiths to start the ball rolling. First up, 'There is a light that never goes out':

#/usr/bin/perl use strict; use warnings; print "Guess the song title:\n"; # 'There is a light that never goes out' (The Smiths) my $light = 1; while (1) { $light = 0 if 1 < 0; print "Light is ", $light ? "on" : "off", "\n"; sleep 1; }

Second example, 'Some girls are bigger than others':

#/usr/bin/perl use strict; use warnings; print "Guess the song title:\n"; # 'Some girls are bigger than others' (The Smiths) for my $girl (1..5) { print "Girl number $girl is size ", int( rand 20 ), "\n"; sleep 1; }

And finally for now, 'Stop me if you think you've heard this one before':

#/usr/bin/perl use strict; use warnings; print "Guess the song title:\n"; # 'Stop me if you think you've heard this one before' (The Smiths) my %heard_before; my @joke_topics = ('penguin', 'chicken', 'elephant', 'badger', 'ape'); JOKE: while (1) { my $topic = $joke_topics[ int( rand 5 ) ]; print "Did you hear the one about the $topic...?\n"; if ($heard_before{ $topic }++) { print "...OK you better stop me, I'm repeating myself now.\n"; last JOKE; } sleep 1; }

Any other ideas?

Replies are listed 'Best First'.
Re: Song titles challenge
by dewey (Pilgrim) on Jul 26, 2007 at 19:17 UTC
    Fun! This one is meant to be run more than read:
    #!/usr/bin/perl + use strict; use warnings; print "Guess the song title:\n"; # `The Long and Winding Road' (The Beatles) + my @windr = split /\n/, "| | | + | | + | \\ \\ + \\ \\ + \\ \\ '-_ + \\ ._ '-_ + '-_ ' \\ + '-_ \\ \\ + \\ \\"; my @windl = map { $a = $_; $a =~ y(/\\)(\\/); scalar reverse $a } @windr; my $long = 10; for(1..$long){ print "$_\n" for @windr; print "$_\n" for @windl; }

    ~dewey
Re: Song titles challenge
by mr_mischief (Monsignor) on Jul 26, 2007 at 22:23 UTC
    Am I in time to do the first OO one?
    #!/usr/bin/perl use strict; use warnings; print "guess the song title:\n"; ### I Hate myself and I want to die (Nirvana) package me; sub new { my $class = shift; my $self = {}; bless ( $self, $class ); return $self; } sub die { my $self = shift; CORE::die(); } sub hate { my $self = shift; --$self->{'esteem'}; } package main; print "life? meh.\n"; my $self = me->new(); $self->hate() && $self->die();
Re: Song titles challenge
by Anonymous Monk on Jul 27, 2007 at 00:07 UTC
    #!/usr/bin/perl use strict; use warnings; print "Guess the song title:\n"; ### 'Eternal Flame' (that girl band) my @topics = ( 'this site needs more colours', 'tabs are tabbier than spaces', 'PHP rulez ok !!!1!!1', ); print "$topics[rand @topics]\n" while 1;
Re: Song titles challenge
by thezip (Vicar) on Jul 27, 2007 at 00:42 UTC

    I had fun coding this one awhile back ... (Does it still count?)

    Yeaaah, Shagadelic baby!


    Where do you want *them* to go today?
Re: Song titles challenge
by pemungkah (Priest) on Jul 27, 2007 at 22:49 UTC
    A little Brian Eno.
    # "Always Returning I" while(sub{'I'}->()){}
Re: Song titles challenge
by oxone (Friar) on Jul 28, 2007 at 09:21 UTC
    Nice work! I love the humour. Here's a bit of Rolling Stones:
    use strict; use warnings; sub sympathy { print "- Oh you poor thing.\n"; } sub the_devil { print "- The heat down here is terrible.\n"; 666; } sympathy for the_devil;