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?


In reply to Song titles challenge by oxone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.