I'm trying to assign an existing array to an object member variable whose type is array. This should be possible, but I cant figure out how. I will also need to extract the entire array (I know how to get an individual item by indexing). Here is sample code for what I'm trying to do - of course, this code does not produce the desired result(6):
use Class::Struct qw(struct); struct S=>[a=>'$',b=>'@']; #"b" is an array my $a=S->new; my @q=(4,6,7,99); # A local array $a->b(@q); # What I'd like to do - gives syntax err print $a->b(1) # Prints NOTHING .. hoping to see "6" $a->b($q); # Try to assign the $$q to $a->b print $a->b(2) # Prints NOTHING .. hoping to see "7" # Would also like to do my @x = $a->b; % Extract entire array
I guess I'm looking for a overloaded method "b" that accepts an array parameter. I know that $a->b($scalar,$scalar) works fine.
How should I do this ???
Edited 2003-02-28 by Ovid
In reply to Accessing ARRAYS inside objects by NetWallah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |