Guest User

Stream-song reference implementation

a guest
Dec 3rd, 2012
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.70 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # This program outputs the Stream song.
  4. # Input: on command-line
  5. # Output: on STDOUT
  6. use warnings;
  7. use strict;
  8.  
  9. sub echoes {
  10.     my $words=shift;
  11.     my $item=shift;
  12.     my $a="$words $item";
  13.     return "$a\n($a)\n";
  14. }
  15.  
  16. my @items=("stream"); my $r;
  17. print echoes("There was a",$items[0]);
  18. goto B;
  19. A:
  20. $r=shift||exit;
  21. print echoes("And on that",$items[0]);
  22. unshift @items,$r;
  23. print echoes("There was a little",$items[0]);
  24. B:
  25. print echoes("Just a teeny-weeny",$items[0]);
  26. for(1..$#items){
  27.     printf("And the %s was on a %s\n",$items[$_-1],$items[$_]);
  28. }
  29. print "And the stream was on its way...
  30. Where the moon shines high
  31. In the clear blue sky
  32. And all was bright and gay.
  33.  
  34. ";
  35. goto A;
Add Comment
Please, Sign In to add comment