perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Feng He <fen...@nsbeta.info>
Subject A question about the dumplicated named global variables
Date Wed, 07 Nov 2012 04:00:41 GMT
Hello,

Sorry I now have a queston about this case.

I have two PM for config options:

package Config1;
use strict;
require Exporter;

our @ISA = qw(Exporter);
our $example_var;
our @EXPORT = qw($example_var);

$example_var =1;

1;


package Config2;
use strict;
require Exporter;

our @ISA = qw(Exporter);
our $example_var;
our @EXPORT = qw($example_var);

$example_var =2;

1;


In the startup.pl I use both:

use Config1;
use Config2;

Now in the handler one the code is:

package Myhand1;
use Apache2::RequestRec ();
...
use Config1;

our $example_var;

sub handler {

     my $r = shift;
     handle_with($example_var);
}

1;


in the handler two the code is:

package Myhand2;
use Apache2::RequestRec ();
...
use Config2;

our $example_var;

sub handler {

     my $r = shift;
     handle_with($example_var);
}

1;


Finally my question is, since the global variable $example_var is 
defined in both packages Config1 and Config2, and exported by both them.
When I use Config1.pm in handler Myhand1, and use Config2.pm in handler 
Myhand2, will this get conflict? Will the two values of $example_var 
happen to override each other? Why this happens or not happpens?

Thanks in advance.

Regards.

Mime
View raw message