in reply to beatnik poetry generator

Well, if short is the goal, then I suggest  perl -lne '$words{reverse $_}=$_; END{foreach(sort keys %words){print $words{$_}}}' /usr/share/dict/words

Ain't command-line switches grand? Or of course (if you ignore the convenience of reversing a string): perl -F// -lane '$words{join"",reverse @F}=$_; END{foreach(sort keys %words){print $words{$_}}}' /usr/share/dict/words
Though you might consider that overdoing it (or, alternatively, half-assed obfuscation). I just really like autosplit. :-)

To make it a mesmerizing background instead of a printed list, stick a sleep 0.1 statement in the foreach loop. Then remember to look away after a while to refocus your eyes. <grin>

But however you run it, it's cool.

Edit:
Ooh! Ooh! Now I feel just despicably clever. Recalling the Schwartzian Transform and other list-oriented fun, I now present what I'd guess is the shortest possible generator: perl -e 'print sort {reverse ($a) cmp reverse ($b)} <>' /usr/share/dict/words Man, I love list context...


If God had meant us to fly, he would *never* have give us the railroads.
     --Michael Flanders

Replies are listed 'Best First'.
Re: Re: beatnik poetry generator
by Boldra (Curate) on Apr 09, 2001 at 14:04 UTC
    Yes! I Love that last version! Well done!

    One minor cleanup might be:
    perl -e 'print sort {reverse lc($a) cmp reverse lc($b)} <>' /usr/share +/dict/words

    But then, you probably want to skip acronyms altogether, so I'm not sure if that's a good idea.

    And my favourite viewing method is something like this:
    /usr/X11R6/lib/xscreensaver/phosphor -root -delay 50000 -program "beat +nik.pl < /usr/share/dict/words"
    You gotta love the jwz screensavers (perl-hater though he is :).

      The case issue occured to me later, but I don't think it makes much difference--acronyms, as you say, are about it, and there aren't that many of them in the dictionary. I'd figure out how many, but the local Linux boxes are all having screaming fits today, so I can't right now (unless somebody wants to tell me where to find the words file on IRIX, which I'm not convinced is there at all).

      Thanks for the tip on the screen-saver--might have to try that.


      If God had meant us to fly, he would *never* have give us the railroads.
           --Michael Flanders