On Fri, Jun 29, 2001 at 04:07:11PM -0700, Matthew Snelham wrote:
> 
> Why do you have the 'strict refs' pragma turned on if you're bandying about
> references?  Stylistically unneeded, IMHO.

What are you talking about, my friend?  strict refs doesn't disable
using refs - it forces you to use them "correctly."  "Incorrect"
things which are disallowed include using the /name/ of a hash as its
reference, i.e.:

my %hash;
my $hashref = "hash";
%{$hashref}{'foo'} = 'bar';

"Proper" references such as

my %hash;
my $hashref = \%hash;
%{$hashref}{'foo'} = 'bar';

Are still very much allowed.

As to it being stylistically unnecessary - there are many, many Perl
programmers who would disagree with you.

In general, you should always 'use strict', which automatically
includes strict refs, vars, and subs.

This is not to say that I've never done things such as the first
example above - but I usually explicitly turn off strict refs ('no
strict refs') in order to do so.  And I avoid them altogether whenever
I can.

Micah

Reply via email to