Array in Object Question

A

afrinspray

I have a quick question about accessing an array reference from an
object hash.

Say I have an object $obj and it has an array reference that can be
accessed like this:

@{$obj->array}

Does $#{$obj->array} return the length? If not, does @{obj->array} (if
used in the right context)?

Also how would I scroll through each element in the array and change
it's contents (they are string and I want to append something to each
string).

Thanks in advance,
Mike
 
R

roberto0

Hey Mike,

let me get your meaning correctly:

$obj is the object
$obj->array is the array reference

If this is the case, then
$#{obj->array}
should return the index of the last element in the array.

(@{$obj->array})
will evaluate to the size of the array.
$obj->array->[$i] is the $ith element of the array and can be
incremented to parse/change/etc.

cheers,
Rob Anderson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top