Home: Perl Programming Help: Advanced:
Using Java-like URL-based namespaces

New User

May 6, 2002, 11:03 AM

Views: 2576
Using Java-like URL-based namespaces


This is my first post, and I'm a looking for an elegant solution to organizing my Perl code into a namespace structure that fits well into the way that my java code is laid out.

Basically, I want to code and distribute a package called


(based on the same URL as the Java package edu.usc.kmrg.vpdmf)

but then just get these horrendous strings whenever I create a new object. Imagine having

$a = edu::usc::kmrg::vpdmf::blahblahblah->new() scattered around your code.

Is this the only way? I've thought of separating the definition of the library file from the name of the package so I'd put the definition

package blahblahblah;

into the file: ./edu/usc/kmrg/vpdmf/blahblahblah; and then make sure that the package names are all unique, but I'm worried that this will break the Makefile generation process under perl Makefile.PL.

Any suggestions/ideas?




May 7, 2002, 3:46 AM

Views: 2570
Re: [GullyBurns] Using Java-like URL-based namespaces

You could shorten it by creating a global...eg...

use vars qw/$obj/;

$obj = 'edu::usc::kmrg::vpdmf::blahblahblah';

Then you can just use:

$a = $obj->new()