titanandrews
Programmer
Hello,
I see tons of posts about Class::Struct module but unfortunately none of them help me. I have a series of different instances of structs which are stored in a list. I want to be able to modify an element of a list that is in the struct that is stored in the list. Follow that? I am certain my syntax is the problem, but I just can't figure it out. Here is a simple example of what I am trying to do:
I get: "Can't modify non-lvalue subroutine call" compiler error.
I have also tried other methods of changing this value but have failed. Does anyone know?
many thanks,
Barry
I see tons of posts about Class::Struct module but unfortunately none of them help me. I have a series of different instances of structs which are stored in a list. I want to be able to modify an element of a list that is in the struct that is stored in the list. Follow that? I am certain my syntax is the problem, but I just can't figure it out. Here is a simple example of what I am trying to do:
Code:
use Class::Struct;
struct defs =>
{
name => '$',
types => '@',
};
my @alldefs;
my $defs = defs->new( name => 'Fred',
types => ('this','that');
push(@alldefs,$defs);
my $otherdefs = defs->new( name => 'Bilbo',
types => ('loot','boot');
push(@alldefs,$otherdefs);
# --- Modify the name of element 0. THIS DOES WORK!
$alldefs[0]->name = 'Barry';
# --- BUT HOW DO I GET TO AN ELEMENT OF THE LIST??
$alldefs[0]->types(0) = 'toot';
I get: "Can't modify non-lvalue subroutine call" compiler error.
I have also tried other methods of changing this value but have failed. Does anyone know?
many thanks,
Barry