User:MikeMol/Musings

From Rosetta Code

Here, I put observations that don't quite belong in the rest of the wiki.

Spam

The output of Loop/Infinite could be improved with something along these lines:

<lang perl>#!/usr/bin/perl use Time::HiRes qw(usleep); use strict; my $spam = 1; my $out;

my @suffixes = ("",

               ", bacon",
               ", eggs",
               ", bacon, eggs");

$|++;

print "Menu:\n"; print "Spam.\n";

while(1) {

 usleep(750000);
 foreach my $suffix (@suffixes)
 {
   print "Spam";
   for(my $spamcount = 0; $spamcount < ($spam - 1); ++$spamcount)
   {
     usleep(250000);
     print ", spam";
   }
  usleep(250000);
  print $suffix;
   usleep(500000);
   print " and spam\n";
 }
 ++$spam;

}</lang>