package Dice::Die; $VERSION = 0.04; use strict; sub get_size { (shift)->{size}; } sub new { my $init = shift; my $class = ref($init) || $init; my $size = shift; return bless {size => $size}, $class; } sub roll { my $self = shift; my $count = shift || 1; my $size = $self->{size}; return map {int(rand($size) + 1)} 1..$count; } 1; #### sub roll { my ($self) = shift; my $diRef = $self->get_di; my ($total, @roll); foreach my $di ( @$diRef ) { my $rolled = $di->roll(); push( @roll, $rolled ); $total += $rolled; } $self->set_total($total); $self->set_dice(\@roll); return $total; }