On Wednesday, September 24, 2003, at 05:44 PM, Eric Lease Morgan wrote:

How do I insert a list into an object's attribute?

[...]

I suppose I could stuff a reference to the @ids array into $self->{term_ids}
like this:


if (@ids) { $self->{term_ids} = [EMAIL PROTECTED] }

Exactly!


But then how do I dereference items in my object?

sub foo { my ($self) = @_; my $ids = $self->term_ids; # How to dereference a variable that holds an array ref: foreach (@$ids) { ... } }

sub bar {
    my ($self) = @_;
    # How to dereference an expression that returns an array ref:
    my @ids = @{ $self->term_ids };
    foreach (@ids) { ... }
}

HTH,

Paul.

--
Paul Hoffman :: Taubman Medical Library :: Univ. of Michigan
[EMAIL PROTECTED] :: [EMAIL PROTECTED] :: http://www.nkuitse.com/



Reply via email to