in reply to RE: Re: Closures and scope
in thread Closures and scope

It's not a problem, it's a good idea.

Lexical scoping is a very good thing because it means that when you use a module written by someone else, or when more than three or four people are working on a project at a time, a variable in one place won't clobber a variable somewhere else with the same name.

I won't say that the innards aren't a little messy (and I haven't read the regex code, so I don't have to roll for Sanity), but the way it works makes sense, and fits the Do What You Mean principle fairly well.

As for why my isn't the default in subroutines, there are two good reasons. First, it would have broken backwards compatibility between Perl 4 and Perl 5. The goal there was to minimize breakage. Second, it's the same reason 'use strict' isn't always on by default -- sometimes, quick and dirty scripts can use global variables and no one cares.