SPUG: How to deal with same name packages?
tuck at whistlingfish.net
Mon Jan 14 17:13:45 CST 2002
-- c k <thasone at yahoo.com> spake thusly:
> Is there a way to deal with same name
> packages/modules/classes/objects in perl?
> I created a Link.pm and used that with LWP in a main
> script (e.g., put use Link; and use LWP; near the
> top). I believe my Link.pm is clashing with another
> module named Link.pm in LWP, because when I change my
> Link.pm to Lynk.pm things work fine.
> Besides changing my module name from Link.pm to
> Lynk.pm, is there another way to deal with same name
> packages in Perl? For example, in C you can do this,
># if !defined LinkH
># define LinkH
> some stuff ...
> Can I do that in Perl? Is there a technique for doing
The best way to do this is just give it a different name. Fortunately,
namespaces in Perl include the path, so 'package Link' is not the same
as 'package LWP::Link' or 'package HTTP::URL::Link' (not that said
Just out of curiosity, is it possible that you're not putting a package
declaration in your Link.pm? Does it make a difference if you switch
the order of the use statements?
It also might help if you gave actual error messages and code snippets.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/archives/spug-list/attachments/20020114/575de685/attachment.bin
More information about the spug-list