You know, I could have done something productive with my time tonight... To my credit, I was able to stop this silliness before I finished Perl-ing the whole song.
use Person; use Bar qw/:smoky/; my $piano_man = Person->new( name => 'Billy Joel' ); ### it's 9:00 on a Saturday. a regular crowd shuffles in my @crowd = (); if ( (localtime time)[2] == 21 and (localtime time)[6] == 6) ) { splice(@crowd, rand(@crowd), 0, Person->new) for (1 .. $regular); } ### there's an old man sitting next to me, making love to his tonic an +d gin. my $mypos = $piano_man->position_in(@crowd); my $old_man = Person->new( gender => 'M', position => 'sitting', age = +> 70, figurative_sexual_partners => [ $tonic, $gi +n ] ); splice(@crowd, $mypos+1, 0, $old_man); # .. insert the rest of verse one here ... my @us = @crowd[ 0 .. ($mypos-1), ($mypos+1) .. $#crowd ]; ### sing us a song, you're the piano man. sing us a song tonight ((localtime time)[2] > 18) and $piano_man->sing( $songs[rand(@songs)], @us ); ### well, we're all in the mood for a melody and you've got us feeling + alright. my $alright = ($bad + $good)/2; for (@us) { $_->set_mood_flag(1 << MELODY); $_->feel_emotion($alright); }
My favorite part is the "shuffles in" part -- I'm not familiar with the "real" array shuffling algorithms, but this is random enough for me.

blokhead

Replies are listed 'Best First'.
Re: Piano Man
by nothingmuch (Priest) on Oct 22, 2002 at 11:56 UTC
    use List::Utils qw(shuffle); my @shuffled_crowed = shuffle @crowd;
    Great job!

    -nuffin
    zz zZ Z Z #!perl
Re: Piano Man
by ibanix (Hermit) on Nov 23, 2002 at 13:23 UTC
    Beautiful! Hats off to you!

    <-> In general, we find that those who disparage a given operating system, language, or philosophy have never had to use it in practice. <->