perl coding style question

Mark Fowler mark at twoshortplanks.com
Tue Aug 16 20:32:30 BST 2011


On Tuesday, August 16, 2011, Alex Brelsfoard <alex.brelsfoard at gmail.com>
wrote:

> The code I saw was referencing variables using the $:: pragma:

I sometimes use this in combination with the -s switch.

#!/opt/perl/bin/perl -s

use 5.14;
use warnings;

say STDERR 'reticulating splines'
 unless $::q;

In other words it's a way of me saying, yes, I really want the global var $q
in the main namespace.

(some people might argue I should use 'our' here. They might be right -
especially in the case where I use a command lone switch only once, in which
case warnings will ommit a warning)

Mark

Typed on mobile Internet thingy, expect typos, autocorrect, etc.


More information about the london.pm mailing list