[VPM] Help in reference
Darren Duncan
darren at DarrenDuncan.net
Thu Dec 2 19:32:47 CST 2004
On Thu, 2 Dec 2004, Philip Yuson wrote:
> I am having a problem with a script.
> The script defines two instaces of a class ($o an $j of package parse)
> The parse package defines an array reference. For some reason, it
> defines the same reference address for both packages:
>
> sub build {
> my $self = shift;
> my $a = [];
> return $a;
> }
>
> my $o_a = $o->build;
> my $j_a = $j->build;
>
> if you print $o_a and $j_a, they both have the same reference address:
> ex: ARRAY(0X94ce680)
>
> The build method is a lot complicated but I just shortened it.
>
> Is this a bug in Perl or is this a bug in my program?
Does this bug still occur in your shortened version? If it does,
then...
Try renaming $a to
something else. The names $a and $b have special meanings to Perl, like
$_ does, though possibly only in certain contexts like explicit sorting.
See if it works with a name like $foo instead of $a.
-- Darren Duncan
More information about the Victoria-pm
mailing list