How do I insert a list into an object's attribute? MyLibrary is in the process of being rewritten in an object-oriented manner. One of the objects are librarians. Librarians are intended to be classified with one or more subject terms. In the manner of good relational databases, each subject term is associated with a key value in the form of an integer. Consequently, my librarian objects have attributes such as name, email address, and telephone number.
I would also like to stuff a list if key values (id's) into the librarian object denoting what subject(s) the librarians are associated. While I have been able to add simple scalars to the librarian object, I don't know how to add a list. This is what I have so far: # create a librarian object my $librarian = MyLibrary::Librarian->new(); # assign keys (id's) to the librarian object $librarian->term_ids(1, 2, 3, 4); # this only prints the number 4; how can it all the numbers? foreach my $t ($librarian->term_ids) { print "id: $t\n" } sub term_ids { # get myself and then the ids my $self = shift; my @ids = @_; # check for ids and add them if (@ids) { $self->{term_ids} = @ids } # return return $self->{term_ids}; } Alas, this code does not work because the print statement only prints the number 4. I suppose I could stuff a reference to the @ids array into $self->{term_ids} like this: if (@ids) { $self->{term_ids} = [EMAIL PROTECTED] } But then how do I dereference items in my object? Again, what are some good ways to insert a list into the attribute of a object? -- Eric Lease Morgan University Libraries of Notre Dame (574) 631-8604