Games, Diversions & Perl Culture

Book description

The Perl Journal (TPJ) did something most print journals aspire to, but few succeed. Within a remarkable short time, TPJ acquired a cult-following and became the voice of the Perl community. Every serious Perl programmer subscribed to it, and every notable Perl guru jumped at the opportunity to write for it. Back issues were swapped like trading cards. No longer in print format, TPJ remains the quintessential spirit of Perl--a publication for and by Perl programmers who see fun and beauty in an admittedly quirky little language.Games, Diversions, and Perl Culture is the third volume of The Best of the Perl Journal, compiled and re-edited by the original editor and publisher of The Perl Journal, Jon Orwant. In this series, we've taken the very best (and still relevant) articles published in TPJ over its 5 years of publication and immortalized them into three volumes.The 47 articles included in this volume are simply some of the best Perl articles ever written on the subjects of games, diversions, and the unique culture of this close-knit community, by some of the best Perl authors and coders. Games, Diversions & Perl Culture focuses on entertaining topics that make Perl users such fanatics about the language. You'll find all of the playful features TPJ offered over the years, including the Obfuscated Perl Contests, Perl Quiz Shows, humor articles, and renowned one-line recipes. The book also contains a panoply of quirky applications of Perl, including genetic algorithms, home automation, music programming, and an entire section on natural language processing.This anthology is an unmatched compendium of Perl lore.

Publisher resources

View/Submit Errata

Table of contents

  1. Games, Diversions, and Perl Culture: Best of the Perl Journal
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Finding Perl Resources
    2. Conventions Used in This Book
    3. Using Code Examples
    4. Comments and Questions
    5. Acknowledgments
  4. 1. Introduction
  5. I. Culture
    1. 2. Wherefore Art, Thou?
      1. Music to My Ears
    2. 3. TPJ Cover Art: From Camels to Spam
      1. TPJ #1: The Camel
      2. TPJ #2: The Pearl
      3. TPJ #3: RSA on Greenbar
      4. TPJ #4: Etch-a-Sketch.
      5. TPJ #5: Commodities
      6. TPJ #6: Scrabble
      7. TPJ #7: Spiderball
      8. TPJ #8: The Coffee Cup Fiasco
      9. TPJ #9: Drummer/Coder Wanted
      10. TPJ #10: The Underwood Typewriter
      11. TPJ #11: The Conspiracy
      12. TPJ #12: The Atari Perl Cartridge
      13. TPJ #13: Dance Remixes
      14. TPJ #14: Outlook Not So Good
      15. TPJ #15: Braille blocks
      16. TPJ #16: e. e. cummings’ Gravestone
      17. TPJ #17: Napster
      18. TPJ #18: Spam
      19. TPJ #19: Monopoly Money
      20. TPJ #20: WAP
    3. 4. Perl Style
      1. Background
      2. Existing Measures
      3. The Basic Units
      4. The Tool
      5. Usage
      6. Why This Should Be Hard To Do
      7. The Perl Compiler to the Rescue
      8. Future Directions
      9. Acknowledgments
    4. 5. Home Automation with MisterHouse
      1. HA! Perl?
      2. MisterHouse
      3. Objects in the Home
      4. Talking and Listening
      5. A Smart TV Guide
      6. Whole House CallerID
      7. Squeaky Stairs
      8. You Have Mail
      9. Say What?
      10. Give Your House a Brain
    5. 6. Home Automation: The X10 Nitty-Gritty
      1. Simple Output Commands: The CM17
      2. The ControlX10::CM17 and ControlX10::CM11 Modules
      3. What’s in a Command?
      4. Timing Issues
      5. Bidirectional I/O with the CM11
      6. A Few More Considerations
    6. 7. A Day in the Life of comp.lang.perl.misc
      1. A Little History
      2. How the “Day in the Life” Was Done
      3. The Raw Statistics
      4. The Day’s Weather Report
      5. Netiquette Nits
      6. The Regulars
      7. The Future of comp.lang.perl.misc
  6. II. Science
    1. 8. Perl-fect Sundials
      1. Building Your Own
    2. 9. Genetic Algorithms
      1. The Genetic Code
      2. Assembling an Organism
      3. Survival of the Fittest
      4. Sex and Mutation
      5. The Terrifying Results
      6. Other Applications
      7. Going Further
      8. Other Fitness Functions
      9. Resources
    3. 10. How Perl Saved the Human Genome Project
      1. Bioinformatics and Perl
      2. Other Uses for Perl
      3. Problems with Perl
    4. 11. PDL: The Perl Data Language
      1. The perldl Shell
      2. Listing of a Few PDL Functions
      3. Where Are We Now?
  7. III. Language
    1. 12. Chatbot::Eliza
      1. How It Works
      2. What Now?
      3. References
    2. 13. Infobots and Purl
      1. IRC
      2. Bots and Infobots
      3. So What?
      4. Are You Spongeworthy?
      5. You Can’t Do That in Public!
      6. What Are You Thinking?
      7. Idiot Savant
      8. A Sense of Play
      9. What? We Ordered No Pizzas!
      10. Future Directions
      11. Where to Get It
      12. Acknowledgments
      13. References
    3. 14. Speech Synthesis
      1. Pre-Recorded Sentences
      2. Lexical Synthesis in One s///
      3. The Out-of-Vocabulary Problem: Synthesis in One s///e
      4. Text-to-Phoneme Conversion
      5. More Context: Two Substitutions
      6. What Else?
      7. References
    4. 15. Lazy Text Formatting
      1. Text::Autoformat
      2. Paragraphs
      3. Quoting
      4. Lists
      5. Quotations
      6. Widows
      7. Justification and Sentencing
      8. Future Features
    5. 16. Perl and MIDI: Simple Languages, Easy Music
      1. Hard Things Possible
      2. Approach 1: A Novel Language
      3. Approach 2: An Extensional Language
      4. Easy Things Easy
      5. Behold MIDI::Simple!
      6. “Relative” Notes
      7. Percussion, Uniformity, and noop
      8. The Object-Oriented Interface
      9. Using synch, and Some Actual Music
      10. Mod, Canons, and Rounds
      11. Future Features
      12. References
    6. 17. Braille Contractions and Regular Expressions
      1. Braille and Contractions
      2. Sample Text in Braille
        1. Linguistic Rule Systems
        2. Generativity Systems
        3. Optimality Systems
        4. Regex Replacement as a First Hack
        5. Contexts in Regular Expressions
        6. Embedding Code in Regular Expressions
        7. Rules as Exceptions
        8. Testing It
        9. It’s Alive!
    7. 18. Hypernyms, Hyponyms, Pertainyms, and Other Word Relationships
      1. Concepts in Wordnet
      2. Converting the Data
      3. Installing Lingua::Wordnet
      4. Basic Usage
      5. Movin’ It Up a Level
      6. Other Word Relationships
      7. Other Useful Functions
      8. What’s Next?
    8. 19. Parsing Natural Language
      1. I See a Pattern Developing
      2. Link Grammar
      3. Lingua::LinkParser
      4. Irregular Regular Expressions, Overloaded
      5. What Sucks? What Rocks?
      6. What Sucks, Regex Style
      7. The What-Sucks-Ometer
      8. There’s Lots More Here
      9. References
      10. A Full Lingua::LinkParser Example
    9. 20. Word Morphology
      1. Morphology: Word Form and Structure
      2. Morphological Analysis and Perl
      3. Constructing a Word Frequency List
      4. Morphological Inflections and Derivations
      5. Representing a Single Rule
      6. Representing Many Rules
      7. Telling Good from Bad
      8. The Key Insight!
      9. Implementing It
      10. Applying the Derivation Process to All Tokens
      11. Summary
      12. Future Work
    10. 21. Smart Matching for Human Names
      1. Installing the Modules
      2. Module Contents
      3. Using the Modules
      4. What They Do
      5. Matching Nicknames
      6. Conclusion
    11. 22. Localizing Your Perl Programs
      1. A Localization Horror Story: It Could Happen to You
      2. The Linguistic View
      3. Breaking gettext
      4. Replacing gettext
      5. Buzzwords: Abstraction and Encapsulation
      6. Buzzword: Isomorphism
      7. Buzzword: Inheritance
      8. Buzzword: Concision
      9. The Devil in the Details
      10. Proof in the Pudding: Localizing Web Sites
      11. References
    12. 23. Internationalized Sorting
      1. Default sort Versus “Normal” English Sorting
      2. Locale-Based Sorting
      3. Spanish: Cana y Caña
      4. Spanish: Chorizo, Chimichangas, Chicharrones, y Churros
      5. Bi-Level Sorting to the Rescue
      6. English: Résumé and Resume
      7. Optimizing with Memoization
      8. Sorting it All Out
    13. 24. Simulating Typos with Perl
      1. Simulating the Typos
      2. How to Identify Words
      3. Typos in Other Languages
      4. Results
      5. References
    14. 25. Correcting Typos with Perl
      1. Why Was It Written?
      2. How Does It Work?
      3. The Sub::Approx Module
      4. The Symbol::Approx::Sub Module
      5. Future Plans
      6. Afterword
    15. 26. Learning Japanese with an HTML Filter
      1. The Web
      2. Dictionary Database
      3. The CGI Script
      4. Taking It a Step Further
      5. Conclusion
      6. wwwkan.pl
  8. IV. Games and Quizzes
    1. 27. Games in Perl
      1. Strategy Games
      2. Cards
      3. Dice
      4. Word Games
      5. Twitch Games
    2. 28. The Prisoner’s Dilemma
      1. The Iterated Prisoner’s Dilemma
      2. The Three-Way Prisoner’s Dilemma
      3. The Prisoner’s Dilemma Programming Contest
      4. Results of the Contest
    3. 29. The Rezrov Infocom Game Interpreter
      1. Resurrecting the Z-Machine
      2. Enter the Camel
      3. What’s It Do?
      4. The Joy of vec
      5. Tinkering with the Z-Machine
      6. Teleport
      7. Bamf
      8. Pilfer
      9. Universal Command Set
      10. Interface Abstraction
      11. Performance Considerations
      12. Quantity Is Job One
      13. A Plea for Inlining
      14. Conclusion
      15. References
    4. 30. Tktk: A Perl/Tk Solitaire Game
      1. The Rules
      2. A First Cut
      3. Shuffling
      4. Layout
      5. Show the Tableau!
      6. Would You Like to Play a Game?
      7. Making the Moves
      8. Laying the Base
      9. Pickup Lines
      10. Oops!
      11. Finishing Touches
    5. 31. The First Perl/Internet Quiz Show
      1. Toss-up Questions
      2. Bonus Questions
      3. The Answers
        1. Toss-up Answers
        2. Bonus Answers
    6. 32. The Second Perl/Internet Quiz Show
      1. Sample Questions
      2. Toss-up Questions
      3. Bonus Questions
      4. The Answers
        1. Toss-up Answers
    7. 33. The Third Perl/Internet Quiz Show
      1. Toss-up Questions
      2. Bonus Questions
        1. Toss-up Answers
        2. Bonus Answers
    8. 34. The Fourth Perl/Internet Quiz Show
      1. Toss-up Questions
        1. Bonus Questions
      2. Toss-up Answers
      3. Bonus Answers
    9. 35. The Perl Whirl Quiz Show
      1. Toss-up Questions
      2. Bonus Questions
      3. Toss-up Answers
      4. Bonus Answers
    10. 36. The Perl Wizard’s Quiz
      1. Answers
  9. V. Poetry
    1. 37. Just Another Perl Haiku
      1. The Tao of Haiku
      2. Haiku Online
      3. Artificial Haiku
      4. The Coy Module
      5. A Note About the Name
      6. Inside the Coy Module
      7. Mere Words
      8. Random Harvesting
      9. Filling in the Blanks
      10. The Other Type of Grammar
      11. Counting the Beat
      12. But Does the Bear Dance?
      13. Extending the Module
      14. Is There a Poet in the House?
      15. It Seemed Like a Good Idea at the Time
    2. 38. Searching for Rhymes with Perl
      1. Where to Look
      2. Preparing the Data
      3. Searching the Prepared Data
      4. Counting Syllables
      5. Coping with (Syllabic) Stress
      6. A Simple mpron Searcher
      7. Accommodating Another Notation
    3. 39. The Perl Poetry Contest
      1. The Categories
      2. The Results
        1. Best Poem Port
        2. Haiku
        3. A Perl Program That Generates Poetry
        4. Obfuscated Poetry?
        5. Best of Show
  10. VI. Politics
    1. 40. Pairwise Voting
      1. The Preference Ballot
      2. Impossibility Theorems
      3. The Borda Method
      4. The Hare Method
      5. Pairwise Election Methods
      6. Condorcet’s Method
      7. Smith’s Method
      8. Copeland’s Method
      9. The Algorithms
      10. The Pairwise Engine
      11. Using CGI to Spit It All Out
      12. Random Thoughts
      13. References
      14. Sites
    2. 41. Secure Internet Voting
      1. About Secure Elections
      2. The Database Schema
      3. Generating VRNs
      4. The E-Ballot
      5. The vote Program
        1. Lines 0–4: Load Modules
        2. Lines 5–7: Define Constants and Globals
        3. Lines 8–9: Connect to the Database
        4. Lines 10–20: Start the Page
        5. Lines 21–22: Initialize Globals
        6. Lines 23–26: Handle a Submitted Ballot
        7. Lines 27–30: Generate a New Ballot
        8. Lines 31–34: Finish up
        9. Lines 40–60: get_globals Subroutine
        10. Lines 61–71: The generate_ballot Subroutine
        11. Lines 72–104: The voting_matrix Subroutine
        12. Lines 105–116: The registration_number Subroutine
        13. Lines 117–123: The vote Subroutine
        14. Lines 124–165: The validate Subroutine
        15. Lines 166–205: The enter_ballot Subroutine
        16. Lines 209–223: Utility Subroutines
      6. Tallying the Votes
    3. 42. Perl and Nuclear Weapons Don’t Mix
      1. A Little Rocket Science
      2. Red Alert!
  11. VII. Obfuscated Perl
    1. 43. The Zeroth Annual Obfuscated Perl Contest
      1. The Categories
      2. How It Works
      3. Hints and Suggestions
      4. So There You Have It
      5. Results
        1. Best Four-Line Signature
        2. Most Powerful
        3. Most Creative
        4. Best “The Perl Journal”
    2. 44. The First Obfuscated Perl Contest
      1. Results
        1. Most Powerful
        2. Most Creative
        3. Best “The Perl Journal”
        4. Best Year 2000 Error
        5. Best of Show
    3. 45. The Third Obfuscated Perl Contest
      1. Most Powerful
      2. Most Creative
      3. Best “The Perl Journal”
      4. Best of Show
    4. 46. The Fourth Obfuscated Perl Contest
      1. Results
        1. The First Circle: Print “The Perl Journal”
        2. The Second Circle: Do Something Powerful
        3. The Third Circle: Be Creative
        4. The Fourth Circle: Make Believe You’re Another Language
    5. 47. The Fifth Obfuscated Perl Contest
      1. Results
        1. Create a Diversion
        2. World Wide Wasteland
        3. Inner Beauty
        4. The Old Standby
    6. 48. One-Liners
      1. Useful One-Liners
        1. How to Use the Perl Debugger as a Command-Line Interpreter
        2. Picking Random Elements from an Array
        3. Evaluating Expressions Inside Double Quotes
        4. Little-Known Magic Scalar Variables
        5. A Demonstration of Perl/Tk Widgets
        6. Using Perl from Emacs
        7. Using Perl from vi
        8. Finding Substrings
        9. Simple Numeric Tests
        10. Adding a Long List of Numbers on the Command Line
        11. Printing Perl’s Include Path
        12. Extracting Unique Elements from a List
        13. Extracting, Sorting, and Printing Unique Words from a File
        14. Counting the Number of Lines in a File
        15. Counting Pod and Code Lines
        16. Separating the Header and Body of a Mail Message
        17. Sleeping for Less Than a Second
        18. Listing Installed Modules
        19. Another Way to List Installed Modules
        20. Preserving Case in a Substitution
        21. Finding the Longest Common Prefix and Suffix
        22. DeMorgan’s Rule
        23. Uuencoding Attachments
        24. When to Split and When to m//g
        25. Transposing a Two-Dimensional Array
        26. Suppressing Backquote Interpolation
        27. Stripping the Eighth Bits from a String
        28. Replacing Tabs with Spaces
        29. A Cheap Alarm Clock
        30. Primality Testing with a Regular Expression
        31. Factoring Numbers
        32. Little-Known Facts About qr
        33. Halving an Array
        34. Daylight Savings Time
        35. Tracking File Progress
        36. Timing Your Program
        37. Stringifying Data Structures
        38. Indenting a Here Document
        39. Printing All Capitalized Words
        40. Generating Randomly-Colored xterms
        41. Extracting PostScript from Windows-Generated PCL Files
        42. Graphing a Bent Torus with PDL
        43. Detecting Unbalanced Parentheses, Brackets, and Braces
        44. Extracting Parenthetical Contents
        45. Converting a GIF Image to an HTML Table
        46. Identifying CVS Files That Aren’t Up To Date
        47. Displaying All Perl’s Error Messages
        48. How to Patch Your Netscape Binary to Enable Strong Encryption
        49. A Little-Known Way to Create References
      2. Not So Useful One-Liners
        1. Regular Expression Epigram
        2. Avoiding Asteroids with Perl
        3. Maze Generation
        4. The Pontifex Cryptosystem
        5. Perl in Sphere, the Movie
        6. An Absurd Way to Convert from Decimal to Binary
        7. Swatch Internet Time
        8. The Game of Life
        9. Ransom Notes
        10. Triggering the F00F Pentium Bug
        11. Magic Cards
        12. Perl Poem: down.pl
        13. Perl Poem: 143
        14. Perl Poem: If Dr. Seuss Were a Perl Programmer
        15. Perl Poem: Object-Oriented Perl
        16. Happy Birthday!
  12. Index
  13. Colophon
  14. Copyright

Product information

  • Title: Games, Diversions & Perl Culture
  • Author(s): Jon Orwant
  • Release date: May 2003
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596003128