in reply to [RFC] Module code and POD for CPAN
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 } }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [RFC] Module code and POD for CPAN
by Bod (Parson) on Apr 14, 2021 at 11:20 UTC | |
by choroba (Cardinal) on Apr 14, 2021 at 12:26 UTC | |
by Bod (Parson) on Apr 14, 2021 at 12:43 UTC | |
by jwkrahn (Abbot) on Apr 14, 2021 at 16:52 UTC | |
by Bod (Parson) on Apr 14, 2021 at 18:53 UTC |