I thought there was an export function that allows you to do this. One
package can export its vars and subroutines to another. There are many
packages that do this, perhaps you could look at one of them (ie: CGI).

The other option to think about Eugene is the way I do it.  I have a single
script that is calling many other scripts.  I accomplish this with a do
<scriptname>. They share variables with the "our" key word. Perhaps you're
barking up the wrong tree, and you need to approach this from a different
angle.  Instead of making them packages, you could make them all individual
scripts.  

HTH
-Wayne

> -----Original Message-----
> From: Haimov, Eugene [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 29, 2003 8:26 AM
> To: Activeperl (E-mail)
> Subject: RE: Query about Variable Scope Across packages and Across
> files...
> 
> I assume, the reason you need to retieve $A::ScopeVariable without the
> package name is that you want to call B::main() from different packages.
> 
> Well, technically, the way you say it - this doesn't look to be possible.
> 
> However, there are some work-arounds that you may consider:
> - pass parameters to your B::main(), or
> - Put together one special package that will host the data
>   that you need to be visible from everywhere, and always use
>   that package name.
> 
> HTH,
> Eugene Haimov.
> 
> -----Original Message-----
> From: Aditya Prasad [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 29, 2003 3:07 AM
> To: Activeperl (E-mail)
> Subject: Query about Variable Scope Across packages and Across files...
> 
> 
> 
> Hello,
> I am having a series of packages that call other packages one after the
> other. Let assume that i have two packages A and B. All of these are
> implemented in  seperate files. Typically package A's subroutine would
> call a sub routine in package B.
> 
> If i declare a variable in a subroutine in package A, is there any way of
> accessing this variable in package B's subroutine that is called from A
> without having to specify the package name?
> 
> Consider the example below:
> 
> A.pm
> ====
> package A;
> use B;
> sub main{
> #ScopeVariable here should be accessible in package B
> $ScopeVariable = "In Package A";
> B::main();
> }
> 1;
> 
> B.pm
> ====
> package B;
> use C;
> sub main{
> #the ScopeVariable in A::main should be accessible here, without having to
> specify the package name, is this possible?
> }
> 1;
> 
> I know for sure that if i use an access specifier $A::ScopeVariable then
> it will work fine. I have tried various scope specifiers like my, local
> and ours.
> thanks in advance,
> aditya
> 
> **************************Disclaimer************************************
> 
> Information contained in this E-MAIL being proprietary to Wipro Limited is
> 'privileged' and 'confidential' and intended for use only by the
> individual
>  or entity to which it is addressed. You are notified that any use,
> copying
> or dissemination of the information contained in the E-MAIL in any manner
> whatsoever is strictly prohibited.
> 
> **************************************************************************
> *
> 
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to