Here's an often-used, but little-remembered fact about Perl that has caused some confusion on more than one occasion: $a and $b are special. They are (among other things) used in custom sort blocks, but unfortunately the Perl documentation uses them...

Here's an often-used, but little-remembered fact about Perl that has caused some confusion on more than one occasion: $a and $b are special.

They are (among other things) used in custom sort blocks, but unfortunately the Perl documentation uses them in many examples. I say that it is unfortunate because the use strict; pragma seems to ignore these two variables. If you do the following:

use strict;

$a = "foo";$b = "bar";$c = "baz";$d = "quux";

You will see that only $c and $d are flagged as errors.

My advice is to avoid using $a and $b except for custom sort blocks and other places that require their use.

Subscribe to ActiveState Blogs by Email

Email Address: *

Thank you for signing up to receive an email notification when we have posted a new blog.

Note: To ensure proper delivery of our emails, take a moment now and add us
(marcom@activestate.com) to your trusted sender list or company white list.

Share this post:

kj is ActiveState’s Systems Administrator. He was born in London, Ontario, grew up in North Vancouver, and spent several years in the Northwest Territories doing technical sales. As a technical infrastructure specialist, he brings over twenty years of systems administration experience to ActiveState.