[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] mv_results and perl
On Wed, 18 Dec 2002, Kevin Walsh wrote:
> for my $row (0 .. $#$ary) {
> my $sku = $ary->[$row]->[0];
> splice(@$ary,$row,1) if $sku eq '1234';
> }
Just picking nits here, but won't that loop skip the row after the one
containing the desired sku, then go past the end of the array? It seems
like you'd want this:
splice(@$ary, $row, 1), last if $sku eq '1234';
if you're dealing with a unique column like the primary key here, or
something like this if dealing with a non-unique column (untested):
my $i = 0;
while ($i < @$ary) {
splice(@$ary, $row, 1), next
if $ary->[$row][1] eq '1234';
++$i;
}
Jon