in reply to Re: Can't retrieve last_record
in thread Can't retrieve last_record

Thanks for the advice.
For the meantime, the prototype mismatch errors are proving to be non-fatal, though annoying.

My intent is to look into rewriting the script in the new year using DBI drivers as I'm told that the Mysql module has been obsoleted

ref: http://search.cpan.org/~capttofu/DBD-mysql-3.0008/lib/Mysql.pm#DESCRIPTION

My concern is the inability to call the method "last_record" on 2 of 12 files.
My understanding is that this method returns the zero-based number of the last record in the .dbf file. We use it to set the upper bound for looping through every record.
As stated, only on 2 of 12 files can this method not be called.

Can a structural abnormality in the FoxPro .dbf files be causing my grief?

Replies are listed 'Best First'.
Re^3: Can't retrieve last_record
by almut (Canon) on Dec 10, 2009 at 22:11 UTC
    My concern is the inability to call the method "last_record" on 2 of 12 files.

    As the error message says ("Can't call method "last_record" on an undefined value"), the method can't be called because what you expect to be an object ($database) is undefined:

    my $database = new XBase $database_file; my $records = $database->last_record() + 1;

    This is most likely because the .dbf file could not be opened/read/parsed, so the constructor fails and returns undef instead of an object to indicate the error.

    In other words, check for this case ($database being undefined), and only continue with the rest of the routine if things are ok.

    And in case you can't simply skip those 2 files, I'm afraid there's more trouble ahead, i.e. figuring out the underlying problem of why the XBase constructor is failing...