On Wed, Feb 18, 2009 at 1:15 PM, Ovid <publiustemp-moduleautho...@yahoo.com>wrote:
> > From: Bill Ward <b...@wards.net> > > > This gives you quite friendly policy identifiers > > > > [ValuesAndExpressions::ProhibitConstantPragma] Pragma "constant" > used at line 22, column 1. (Severity: 4) > > > > What's wrong with 'use constant'? > > Well, nothing's "wrong" with it. It does, however, get clumsy in some > cases. For example: > > use constant FOO => 3; > print $data->{+FOO}; > print "We have @{[FOO]} widgets"; > # or > print "We have ".FOO." widgets"; I would just set a lexical $foo=FOO for most of these situations - especially for including it in a regex > > Versus: > > use Readonly; > Readonly my $FOO => 3; > print $data->{$FOO}; > print "We have $FOO widgets"; > > Readonly constants are just easier to use and have fewer "gotchas". I see. I don't have Readonly in our stack, and I like the performance benefit of the inlined subroutines from constant. I'm just surprised to see that it's considered ungood.