Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

KC's Sunshine (not an original poem)

by KurtSchwind (Chaplain)
on Jan 29, 2015 at 20:12 UTC ( [id://1114970]=poem: print w/replies, xml ) Need Help??

A little bit of KC's Sunshine. Enjoy!

#!/usr/bin/perl # Kurt Schwind: A little of KC's Sunshine use strict; use warnings; my @l = qw( a aah best booty can chance come dance do don't down duty everybody feeling feelings fight floor get give home I in it let's momma now Oh on run shake sister tell the to very well with world yeah you You your You're yourself); sub line { my $j = shift; while(defined $j ) { print $l[$j]." "; $j = shift; } print "\n"; } sub refrain { for(1..6) { print $l[29]." "; } print "\n"; line (29,41,3); line (29,41,3); for(1..6) { print $l[29]." "; } print "\n"; line (29,41,3); line (29,41,3); print "\n"; }; sub groove { for(1..5) { print $l[29]." "; } line (41,3); }; line (1,12,17,27,32,16,23,7); line (9,15,41,14,18,43,0,5); print "\n"; refrain(); line (1,39,4,39,4,8,22,34,35); line (42,32,2,21,32,37,20,4,31); print "\n"; line(26); refrain(); line (26,38); line (29,29,29,29); line (1,29,29,29,29); print "\n"; line(1); refrain(); line(1); groove(); line(1,9,15,32,13); groove(); line(1,18,43,0,5); print "\n"; groove(); line(42,4,8,22,8,22); groove(); line(6,19,36,24,25); groove(); print "\n"; groove(); line(1,28,10,33,30); line(29,29,29,29,27,41,3); line(1,8,41,11); line(29,29,29,29);
--
I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.

Replies are listed 'Best First'.
Re: KC's Sunshine (not an original poem)
by DisneyWizard (Initiate) on Jul 15, 2015 at 00:54 UTC

    One-hundred lines, same dealy-o with identical output, but inspired to minimize content by maximizing subroutine recursion. Contribution by myself, a new to perl newbie, yet seasoned programmer playing now with a headless Raspberry Pi via PuTTY on a msVista laptop. Thanks strangedoc, your example poetry helped me learn function calls and for loops, jumping ahead from Padre/absolute_beginner/05_do_it_again.pl
    It contains one kludge, failing elegance, I couldn't figure out how to make the newline \n print from the word list which forced me to use "if($j==44)" (a position) along with an "else" when I'd rather instead print the 44th value "\n", but at least I'm halfway along the right track I had in mind - stripping out hard coded 'print "\n";' lines by changing them to tokens in the data stream.

    #!/usr/bin/perl # Kurt Schwind: A little of KC's Sunshine # http://www.futuretg.com/FTHumanEvolutionCourse/Audio/English/KC_&_Th +e_Sunshine_Band/KC_&_The_Sunshine_Band_-_Shake_Your_Booty.mp3 use strict; use warnings; my @l = qw( a aah best booty can chance come dance do don't down duty everybody feeling feelings fight floor get give home I in it let's momma now Oh on run shake sister tell the to very well with world yeah you You your You're yourself /n); sub line { my $j = shift; while(defined $j ) { if($j==44) { print "\n"; } else { print " ".$l[$j]; } $j = shift; } } sub sh { my $sh = shift; for(1..$sh ) { line (29); } } sub yb { line (41,3,44); } sub syb { my $m = shift; for(1..$m ) { sh(1); yb(); } } sub refrain { for(1..2) { sh(6); line (44); syb(2); } line(44); } sub groove {sh(5); yb(); }; line (1,12,17,27,32,16,23,7,44,9,15,41,14,18,43,0,5,44,44); refrain(); line (1,39,4,39,4,8,22,34,35,44,42,32,2,21,32,37,20,4,31,44,44,26,44); + refrain(); line (26,38,44); sh(4); line (44,1); sh(4); line (44,44,1,44); refrain +(); line(1,44); groove(); line(1,9,15,32,13,44); groove(); line(1,18,43,0,5,44,44); groove(); line(42,4,8,22,8,22,44); groove(); line(6,19,36,24,25,44); groove(); line(44); groove(); line(1,28,10,33,30,44); sh(4); line(27,41,3,44,1,8,41,11,44); sh(4); line(44,44);

    --
    "I am a sniveling internet programmer, I have a code in my nodes." —(0=8> wiz.
      I'm playing around with de-construction and re-construction given a lyrics text file, to and from a pair of "transporter" files; an alphabetically sorted word list (The tokens, with the zero position set to '/n' newline,) and a token instance order array with which to pick the words in their original order, using zero as the token for new line.

      I still haven't got the \n to print from the token list, but the data sequence code was improved by incrementing each word shift up by one, allowing the CRLF to occupy the proper zero position, allowing the code logic (now inverted) if…else statement to take advantage of the zero with shortened comparison - I've always striven to reduce comparisons to their base. Why use 'if(x<>0)' when 'if(x)' is more versatile?. Why limit to Boolean when a range is available? 'if(x-3)' is also faster than 'if(x!=3)' and now three results are valid - negative, zero, and positive.

      #!/usr/bin/perl # Kurt Schwind: A little of KC's Sunshine # http://www.futuretg.com/FTHumanEvolutionCourse/Audio/English/KC_&_Th +e_Sunshine_Band/KC_&_The_Sunshine_Band_-_Shake_Your_Booty.mp3 use strict; use warnings; my @l = qw(\n a aah best booty can chance come dance do don't down duty everybody feeling feelings fight floor get give home I in it let's momma now Oh on run shake sister tell the to very well with world yeah you You your You're yourself); sub line { my $j = shift; while(defined $j ) { if($j) { print " ".$l[$j]; } else { print "\n"; } $j = shift; } } sub sh { my $sh = shift; for(1..$sh ) { line (30); } } sub yb { line (42,4,0); } sub syb { my $m = shift; for(1..$m ) { sh(1); yb(); } } sub refrain { for(1..2) { sh(7); line (0); syb(3); } line(0); } sub groove {sh(6); yb(); }; line (2,13,18,28,33,17,24,8,0,10,16,42,15,19,44,1,6,0,0); refrain(); line (2,40,5,40,5,9,23,35,36,0,43,33,3,22,33,38,21,5,32,0,0,27,0); ref +rain(); line (27,39,0); sh(5); line (0,2); sh(5); line (0,0,2,0); refrain(); l +ine(2,0); groove(); line(2,10,16,33,14,0); groove(); line(2,19,44,1,6,0,0); groove(); line(41,5,9,23,9,23,0); groove(); line(7,20,37,25,26,0); groove(); line(0); groove(); line(2,29,11,34,31,0); sh(5); line(28,42,4,0,2,9,42,12,0); sh(5); line(0,0);
      "I am a sniveling internet programmer, I have a code in my nodes." —(o=8> wiz.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: poem [id://1114970]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-29 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found