Hi all,
I have my own package which has one array as a global variable. In my main pgm, I use a "for" loop to create objects.
package.pm
our @array;
sub new {
my ($self, $a);
push (@array, $a);
}
main.pl
for ($i=0; $i<=3; $i++) {
$x[$i] = package->new($i);
}
print @x;
The value of @array will not be clear up when I call "new" method. I think that the value of @array will be cleared once I call "new".. like create two different objects.
Any suggestion?
I have my own package which has one array as a global variable. In my main pgm, I use a "for" loop to create objects.
package.pm
our @array;
sub new {
my ($self, $a);
push (@array, $a);
}
main.pl
for ($i=0; $i<=3; $i++) {
$x[$i] = package->new($i);
}
print @x;
The value of @array will not be clear up when I call "new" method. I think that the value of @array will be cleared once I call "new".. like create two different objects.
Any suggestion?