3 ms·
The good news is, you don't have to type "use strict" anymore; it's the default if you opt to declare Perl 5.11 or higher as the minimum for your module or scri
by jrockway 15y ago
The good news is, you don't have to type "use strict" anymore; it's the default if you opt to declare Perl 5.11 or higher as the minimum for your module or script.
People seem to hate typing "my" to declare a variable, but that's fine. I appreciate the number of times that's caught bugs for me, and I appreciate the clarity of scoping it allows for. I never really figured out scoping in Python, because you never declare variables. In Python, you could write:
def foo():
def reset():
x = 0
def inc():
x += 1
def print():
print x
And it would compile, but not be what you mean. In Perl, you'd write:
sub foo {
my $reset = sub { my $x; $x = 0 }
my $inc = sub { my $x; $x++ }
...
}
and know exactly what's going on because you had to explicitly declare $x. You can instantly tell that the Perl is broken. But the Python looks like it works (but doesn't). That, to me, is a big deal.
Of course, it doesn't actually matter because you're not supposed to program like that in Python. But if you chose to anyway, ...
- hythloday 15y agoPython has pychecker, which will catch that error for you (as I understand it solves the same issues that "use strict" does).