Wednesday, March 3, 2010

Parts of Perl you never knew existed

This is a list of some of the darker, scarier, or lesser known areas of Perl. I am going to be grouping them into a set of talks to scare, disgust, and delight the DC Perl Mongers. There is no ordering to them In this post; I am just trying to start a list of talk items.

  • Prototypes
  • what happens when you add a & to the start of a function call (aka why you shouldn't)
  • split in void context
  • goto function
  • values vs variables (a superset of lists vs arrays)
  • wantarray and contexts (void, scalar, list)
  • pseudohashes
  • tie
  • typeglobs
  • PadWalker
  • source filters
  • adding methods to existing classes
  • interpolating things that aren't scalars or arrays
  • when to use each vs keys
  • warnings
    • how to disable certain warnings without affecting other warnings
    • how to add categories
  • B::Deparse, showing the magic Perl does for you
    • while (<>), while (readline), and while(readdir)
    • default values for split, print, etc.
  • do file
  • weird operators
  • special variables
    • %main::
    • $]
    • $"
    • $,
    • $/ and $\
    • %SIG
  • what strict does and why
    • symbolic references
    • barewords
  • regex magic
    • \k
    • \g
    • \G
    • \Q
    • differences between scalar and list context
    • recursion


  1. For regexes, I suggest talking about recursive regular expressions. Scary, mind blowing and awesome all at the same time.

  2. Don't forget to talk about putting code refs or even objects into @INC!

    To find a good list of scary things, try to think of all the situations where "no strict $something" is appropriate and acceptable. That should come up with some interesting cases.

    Also, XS (or rather perlapi) offers a wide range of WTF's. My personal favourite (not part of the API) is how (I think) List::Util creates a "mock" OP for calling rand()/srand() from XS. This is probably surpassed by Chocolateboy's dynamic pp_entersub-replacing in Class::XSAccessor.

  3. Don't forget fun things like Sub::Uplevel. Explaining how it works should scare people pretty well.

  4. @Michael Yeah, recursive regexes are part of it. I put "recursion" and "differences between scalar and list context" under warnings by mistake.

  5. More fun stuff: calling close() with no arguments.


Some limited HTML markup is allowed by blogger: strong, b, i, and a. You may also use em, but I have repurposed it through the magic of CSS to be behave very much like <tt><code></code></tt>.