Showing posts with label considered harmful. Show all posts
Showing posts with label considered harmful. Show all posts

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

Monday, October 12, 2009

Should PERL_UNICODE be considered harmful?

I set PERL_UNICODE to "SDL" as a matter of course when setting up my environment. This means that all of my filehandles will use the UTF-8 PerlIO layer unless the locale says otherwise or a specific layer is chosen explicitly. I do this because I don't want to have to worry about calling binmode or explicitly setting the PerlIO layer when opening a file:
open my $fh, "<:utf8", $filename
or die "could not open $filename: $!"
This has worked fine for me for years; however, recently I have noticed a few problems with it:
  • You cannot compile Perl will it set
  • Many modules fail their tests when it is set
  • Scripts that work just fine in your environment fail in other environments
  • since it affects all filehandles, it could cause bugs in modules (I have never actually seen this)
Given these issues, I am starting to consider PERL_UNICODE harmful and thinking about giving it up.

Does anyone know of any arguments to keep using it, or, conversely, more arguments to stop using it?