"Wiggins d Anconia" <[EMAIL PROTECTED]> wrote:

>
>
>> Hi, this question has to do with importing names from one package into
>another.  In my case, both packages reside in the same file, and I
>simply want to import all the package-global symbols from the one
>package into the other.  Can anyone say how to do this?  Here's a bunch
>of tries that didn't work.
>> 
>
>This doesn't make a lot of sense to me, if you are going to export them
>all why bother? The big reason for the separate packages is to avoid
>namespace pollution, which if you export everything you have just
>counteracted. At least put them in a separate file, and use it?  But to
>each their own....
>

<snip old posts>

Wiggins d Anconia, 

Thanks for your usual helpful answers, which do so much to make this list such a 
treasure trove for beginners.

To answer your valid questions about "why would you want to do that": 

my circumstance is that I have a 10,000 line standalone command-line Perl program 
which I am refactoring into working as both a web app (Apache+Mod_perl+MySQL) and a 
command-line app.  I'm not yet clear on what either the file or object architecture 
will be, which is why I'm not carving pieces out into separate files quite yet.   All 
of the code written so far is pretty tightly coupled, again making it nontrivial to 
partition.  It also has some long CPU-bound computation sequences, and I'm reluctant 
to make changes which would add overhead.  

Long story short, I'm casting about for solutions and trying to find out what all my 
options are.  Even if not applicable to this particular case, it seems reasonable that 
some day you're going to want to import all symbols and semantics from one namespace 
into another (which doesn't have to be main:: ... it could be some other package).   
And it's kind of an interesting question just from an academic perspective.  TMTOWTDI 
with Perl.  

I also find that it's really convenient, for now, to have all my source in one file 
(at least until I'm sure of the new architecture), for the same reason that someone on 
the list has advocated merging all the perl docs into a single file: for supereasy 
search and, in my case, replace.   Also, as I transition into a packaged system of 
namespaces, I have a lot of code that expects a lot of names to be omnipresent (about 
250 total subs, maybe half as object methods and half plain old subroutines); again it 
might be convenient to be able to put names in packages but still have them 
omnipresent until I'm clear how it all fits together.

But you're right, in the end I'll probably end up with packages in their own files, 
included with 'use' just like most normal people would do.  :)

Thanks again!




__________________________________________________________________
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to