in reply to Grouping Objects by Attribute

I'm a bit confused about your "call a subroutine, e.g. callToPrayer, which takes an array of monks as its argument, on each group individually." in combination with "without using references". The only way to pass in an array to a subroutine is by passing a reference to the array. After all, all a subroutine can take is a (possible empty) list (of scalars).

I'd do something like:

my @monks = ...; # Array of Monk objects, with a level method. my %monks_by_level; push(@{$monks_by_level {$_->level()}}, $_) for @monks; while (my ($level, $monks) = each(%monks_by_level)) { callToPrayer($monks) }

If you settle for passing in a list (and hence, losing any reference (no pun intended) to an array), you can do it "without references" (well, the objects you start out with are references) - if you know which levels there are (but you could find out by making another pass):

foreach my $level (1 .. 10) { callToPrayer(grep($_->level() == $level, @monks)); }
The first code fragment needs only one pass over the array of objects - the last fragment needs a pass for each level.