in reply to Iterating over an array of objects, within an object?

Without getting all messy with packages and such, the following may help:

use warnings; use strict; my @objs; push @objs, bless {me => "Object $_"} for 1 .. 3; my $obj = bless {objs => \@objs}; $obj->doStuff (); sub doStuff { my $self = shift; $_->doSomethingElse() for @{$self->{objs}}; } sub doSomethingElse { my $self = shift; print "Visited $self->{me}\n"; }

Prints:

Visited Object 1 Visited Object 2 Visited Object 3

It was the dereferencing that bit you. Note @{$self->{objs}} in the code above.


DWIM is Perl's answer to Gödel