for (my $i = 0; $i < scalar @{$self->{'trolley'}}; $i++) { if (${$self->{'trolley'}}[$i]->{'id'} eq $id) { $self->{'intent'} = undef; splice $self->{'trolley'}, $i, 1; return scalar @{$self->{'trolley'}}; } }
That will not work correctly if you have more than one deletion.
Also, splice on an array reference will not work with all versions of perl.
This should be better:
for ( my $i = $#{ $self->{ trolley } }; $i >= 0; --$i ) { if ( ${ $self->{ trolley } }[ $i ]->{ id } eq $id ) { $self->{ intent } = undef; splice @{ $self->{ trolley } }, $i, 1; return scalar @{ $self->{ trolley } }; } }
In reply to Re: [RFC] Module code and POD for CPAN
by jwkrahn
in thread [RFC] Module code and POD for CPAN
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |