On Monday, July 15, 2002, at 06:27 , Connie Chan wrote:
> Some days ago, I've interested in the using of 'our' var,
> however, I do have some problem on using this with require.
part of what is going on here, is essentially the transition
model from how things were 'possible' in perl4 - before the
perl module was 'the thing'....
> ### Lib 1 ###
package lib1;
name the package so that there is a name space for the 'our'
> use strict;
> our %abc;
> $abc{a} = 1;
> $abc{b} = 2;
1;
> ### EOF Lib 1 ###
you need to have that '1;' as the 'last line'
before the POD.... so that it knows where it stopped.
> ### Lib 2 ###
package lib2;
> use strict;
> our $a = "ME";
1;
> ### EOF Lib 2 ###
>
> ### Script 1 ###
> use strict;
> eval { require "lib1.pl" } or die "lib 1";
> eval { require "lib2.pl" } or die "lib 2";
>
print $lib1::abc{a};
> ### EOF Script 1 ###
notice that in this way you make explicit that
you really meant to use the %abc from the lib1 package.
or say
my $ref = \%lib1::abc;
print "\n $ref->{b} \n";
the alternative strategy is to use the 'exporter' - so
that you export that specific 'variable name' - and hence
the script will be able to 'use it directly'....
At which point you really DO want to be happy with
h2xs as the way to start....
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]