On Friday, May 17, 2002, at 09:34 , Adam Morton wrote:
[..]
>
>
> my $x = 17;
>
> package A;
> $x = 12;
>
> package B;
> $x = 20;
>
> # $x is now 20.
> # $A::x and $B::x are still undefined
and as you notice there is almost no way to make
that fly - since there exists no unique construct
$A::x
what you would want to do is some form of encapsulation game
with:
my $x = 17;
my $y = &A::getX;
my $z = &B::getX;
print "\$x is $x and \$y is $y while \$z is $z\n";
#---------------------The Package Line -------
package A;
sub getX {
my $x = 12;
$x;
}
package B;
sub getX {
my $x = 20;
$x;
}
if you do not do the 'my $x' tricks - then you run into the
side effect game that you were expecting...
All of which leads me to wonder why in God's Green Earth
you would wish to use a 'package' approach to begin with.
given the initial construction of the form
my ($a, $b) = ( '' , '');
$b = sub1($a);
sub2($b);
#-----das boot dives here....
sub sub1 {
my ($inarg) = @_
.....
$myOutArg
}
sub sub2 {
my ($inarg) = @_
.....
$myOutArg
}
would allow us to cope with the scope and pass the return of sub1
to sub2 - yes, you are correct, it would be possible to SUCK IN
and use the "globally" scoped $a and $b - but that also means that
one can not move along to building
package Dornitz::derFleet
undt stuffing all of one's subs into it so that the code would
be simplified to
use Dornitz::derFleet qw/:lant/;
my ($a, $b) = ( '' , '');
$b = sub1($a);
sub2($b);
exit(0);
capish paisano???
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]