if ($attrs) {
$new->throw_exception("attrs must be a hashref")
unless ref($attrs) eq 'HASH';
- while (my ($k, $v) = each %$attrs) {
+ foreach my $k (keys %$attrs) {
$new->throw_exception("No such column $k on $class")
unless $class->has_column($k);
- $new->store_column($k => $v);
+ $new->store_column($k => $attrs->{$k});
}
}
return $new;
sub set_columns {
my ($self,$data) = @_;
- while (my ($col,$val) = each %$data) {
- $self->set_column($col,$val);
+ foreach my $col (keys %$data) {
+ $self->set_column($col,$data->{$col});
}
return $self;
}