Obscure Perl trick: single-quote separators

One of the delights of working in an old language with penchant for backwards-compatibility is discovering some of the artifacts that remain. A couple of weeks ago I was reading perlmod and came across this:

The old package delimiter was a single quote … which was there to make Ada programmers feel like they knew what was going on … the old-fashioned syntax is still supported for backwards compatibility

How interesting! Ada uses a single quote as an attribute delimiter, similar to the possessive in English:


In Perl, I can replace the use of the two colon separator with a single quote. So this simple package declaration and script:

package My::Customer;

sub name { 'Dobby the Sheep' }

package main;

print My::Customer::name();


package My'Customer;

sub name { 'Dobby the Sheep' }

package main;

print My'Customer'name();

You can see that the single quote can replace both namespace separators in the package name, and attribute accessors in the call to name(). Running this code prints “Dobby the Sheep” as expected, but the syntax highlighting is pretty messed up in my editor.


  • A detailed account of the Higher Order Language Working Group that produced Ada
  • You can read perlmod online or at the command line by typing perldoc perlmod.

This article was originally posted on PerlTricks.com.


David Farrell

David is a professional programmer who regularly tweets and blogs about code and the art of programming.

Browse their articles


Something wrong with this article? Help us out by opening an issue or pull request on GitHub