gkovacsp has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Anydata with a CSV file to store data. Adding rows works, but updating does not: It always creates a new row with the updated fields instead on overwriting the original one. This is the content of the CSV file:
value1,value2,value3 apple,0,0 peach,0,0
This is my perl code
use AnyData; $testDB = adTie( 'CSV', "test.db.csv", 'u', { col_names=>'value1,value2,value3' }, { key=>'value1'} ); $testDB->{{value1=>"apple"}}={value2=>"yes"};
Runs without errors, but the CSV file looks the following at the end:
value1,value2,value3 apple,0,0 peach,0,0 apple,yes,0
It added a new "apple" line instead of updating the original one... Any ideas how to make it update the row?

Replies are listed 'Best First'.
Re: Anydata - Update row problem
by ww (Archbishop) on Feb 22, 2013 at 21:33 UTC
    Not sure if this is related, but see the open bugs in RT, esp the first.

    I PPM-installed AnyData this afternoon to kick the tires on your code; then cargo-culted (straight cut'n'paste from the doc) another script... and got only as far as defining the $table at which point, AnyData kicked out an error, squawking that the names I used were NOT valid:

    ERROR: sex is not a column in the table! columns are: name~ fone~ sex~

    I dunno. That's not what the code says... and I realize it's not the same issue you're facing, but vers, OS and other diffs may explain (mine, BTW: Win7, AS Perl 5.015)


    If you didn't program your executable by toggling in binary, it wasn't really programming!