Pomin Wu wrote:
> When accessing CSV with AnyData as a tie hash, I found
> that although the C<while (my $row = each %$table)> syntax
> is valuable, it C<last> as soon as I try to modify the
> table inside the loop, for ex. C<delete $table->{key};>.
> Or have I missed something?
Not sure what you mean. This works:
use AnyData;
my $table = adTie( 'CSV', ["id,phrase\n1,foo\n2,bar\n3,baz"] );
while (my $row=each %$table) {
delete $table->{$row->{id}}
if $row->{id}<3 and $row->{phrase} ne 'bar';
}
But if all you want to do is delete a set of rows, you don't need the
while loop, you can just do something like this which accomplishes the
same thing as the while loop above:
delete $table->{{id=>'< 3',phrase=>'ne bar'}};
If I've misunderstood your question, please send an example of the
offending code.
--
Jeff