Hi,
I wrote a simple program that using Class::ArrayObjects but It did not work as I expected. The program is:
TestArrayObject.pm:
package TestArrayObject;
use Class::ArrayObjects define => {
fields => [qw(name id address)],
};
sub new {
my ($class) = @_;
my $self = [];
bless $self, $class;
$self->[name] = '';
$self->[id] = '';
$self->[address] = '';
return $self;
}
1;
Test.pl
use TestArrayObject;
use Data::Dumper;
my $test = new TestArrayObject;
$test->[name] = 'Minh';
$test->[id] = '123456';
$test->[address] = 'HN';
print Dumper $test;
When I run Test.pl, the output data is:
$VAR1 = bless( [
'HN',
'',
''
], 'TestArrayObject' );
I wonder where is my data for 'name' and 'id'?
Thanks, Minh.