Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Module Naming Dilemma

by Anonymous Monk
on Jan 06, 2005 at 16:48 UTC ( #419985=note: print w/replies, xml ) Need Help??

in reply to Module Naming Dilemma

Why not just use a GLOB reference alias?. This will make package Bar works as an alias for Foo:
*Bar:: = \*Foo:: ;
Here's a sample:
package Foo ; sub new { bless {} } sub test { print "TEST> [@_]\n" ; } package main ; *Bar:: = \*Foo:: ; my $foo = Foo->new() ; $foo->test(123) ; print "$foo\n" ; my $bar = Bar->new() ; $bar->test(456) ; print "$bar\n" ;
TEST> [Foo=HASH(0x1a4ece4) 123] Foo=HASH(0x1a4ece4) TEST> [Foo=HASH(0x15d53dc) 456] Foo=HASH(0x15d53dc)

Replies are listed 'Best First'.
Re^2: Module Naming Dilemma
by Ven'Tatsu (Deacon) on Jan 06, 2005 at 18:26 UTC
    Doing that you have altered the global namespace. If you were to use this in a module then some one could potentialy overwrite another class used in their code or in another module without ever knowing it. Ovid's and gaal's ideas are both compleatly isolated.
    In short your begging to get bit by this code if it's used in production.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://419985]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-09-28 10:39 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (124 votes). Check out past polls.