[Chicago-talk] lowercase package names

JT Smith jt at plainblack.com
Tue Aug 23 07:45:23 PDT 2005


I have news. They are actually enforced in perl, at least partially.

The weird thing is that it does seem to work sometimes, but not always. For instance, if 
I did something like:

package MyModule;
use base 'Foo::bar';
my $self = Foo::bar->new;

But if I want to use another lowercase module it doesn't work.

package MyModule;
use base 'Foo::bar';
use Foo::bar2;
my $foo = Foo::bar->new;
my $bar = Foo::bar2->new;

Likewise it doesn't appear to work if you use multiple inheritance like:

package MyModule;
use base qw(Foo::bar Foo::bar2);
my $foo = Foo::bar->new;
my $bar = Foo::bar2->new;


Anyway, I'm trying to pull off a bit of a jury rig to maintain backward compatibility. I 
had a package that I decided would be better split into lots of small packages as 
subclassed objects. So I was turning the individual methods into package names and using 
AUTOLOAD to redirect method calls to these individual packages. Since the methods are 
lower case it made it easy to use lower case package names. But I can quite easily 
uppercase the first letter in the AUTOLOAD to make it use upper case package names. It's 
just one more extra step.



On Tue, 23 Aug 2005 09:22:48 -0500
  Jim Thomason <thomasoniii at gmail.com> wrote:
> Okay, you piqued my curiousity. Care to share why you need a
> lowercased package name?
> 
> AFAIK, lowercase package names are pragmas by convention, but (like
> damn near everything else in the language) isn't actually enforced in
> any fashion.
> 
> Nor is there anything necessarily special about them. For example, the
> 'vars' pragma. Nothing magical in there at all.
> 
> -Jim.....
> 
> On 8/23/05, JT Smith <jt at plainblack.com> wrote:
>> I know that generally speaking lowercase package names are supposed to be reserved for
>> internal perl stuff, but I have a need to use them and I'm wondering if there's any 
>>code
>> within perl that would prevent it. Anybody know?
>> 
>> And if so, is there any way to disable that check?
>> 
>> 
>> JT ~ Plain Black
>> ph: 703-286-2525 ext. 810
>> fax: 312-264-5382
>> http://www.plainblack.com
>> 
>> I reject your reality, and substitute my own. ~ Adam Savage
>> _______________________________________________
>> Chicago-talk mailing list
>> Chicago-talk at pm.org
>> http://mail.pm.org/mailman/listinfo/chicago-talk
>>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk


JT ~ Plain Black
ph: 703-286-2525 ext. 810
fax: 312-264-5382
http://www.plainblack.com

I reject your reality, and substitute my own. ~ Adam Savage


More information about the Chicago-talk mailing list