Recién instalé el CAM::DBF para probarlo. He hecho un script con todos los "Instance Methods"; algunos van bien pero otros me dan resultados extraños como: ARRAY(0x100a26dc) lo da esta instrucción:
Using perl Syntax Highlighting
#Return a record as a reference to an array of fields.
#Row numbers count from zero.
my $recordtoarray = $dbf->fetchrow_arrayref(0);
#Row numbers count from zero.
my $recordtoarray = $dbf->fetchrow_arrayref(0);
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4
también esta:
Using perl Syntax Highlighting
#Return a record as a reference to a hash of (field name = field value)> pairs. Row numbers count from zero.
my $recordtohash = $dbf->fetchrow_hashref(0);
my $recordtohash = $dbf->fetchrow_hashref(0);
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
me da
- Código: Seleccionar todo
HASH(0x100895f0);
Hasta donde sé, deberían aparecer los campos de la BD, ¿no es así?
¿Me pueden ayudar con este tema? ¿Qué hago para extraer los datos de la de BD?
Saludos y gracias ¿eh?
JC
Por si vale de algo les copio abajo el script tal cual lo ejecuto:
Using perl Syntax Highlighting
#!/usr/bin/perl -w
use CAM::DBF;
# abre la DBF en el modo de lectura
my $dbf = CAM::DBF->new("test.dbf", 'r');
#Return the number of columns in the data table.
my $fields = $dbf->nfields();
#Return a list of field header names.
my $names = $dbf->fieldnames();
#Return a record as a reference to an array of fields.
#Row numbers count from zero.
my $recordtoarray = $dbf->fetchrow_arrayref(0);
#Return a record as a reference to a hash of (field name = field value)> pairs.
#Row numbers count from zero.
my $recordtohash = $dbf->fetchrow_hashref(0);
my $arrayref = $dbf->fetchrows_arrayref(1, 6);
print "$dbf\n";
for ($i = 0; $i <= 5; $i++) {
#Return a the title of the specified column. $i
# can be a column name or number.
#Column numbers count from zero.
my $nameofthecolumns = $dbf->fieldname($i);
#Return the dBASE field type for the specified column.
#$i can be a column name or number. Column numbers
#count from zero.
my $fieldtype = $dbf->fieldtype($i);
#Return the byte width for the specified column. $i
#can be a column name or number.
#Column numbers count from zero.
my $bytewidth = $dbf->fieldlength($i);
#print "Field $i is called: $nameofthecolumns the type is: ".
# "$fieldtype and his byte width is $bytewidth\n";
}
use CAM::DBF;
# abre la DBF en el modo de lectura
my $dbf = CAM::DBF->new("test.dbf", 'r');
#Return the number of columns in the data table.
my $fields = $dbf->nfields();
#Return a list of field header names.
my $names = $dbf->fieldnames();
#Return a record as a reference to an array of fields.
#Row numbers count from zero.
my $recordtoarray = $dbf->fetchrow_arrayref(0);
#Return a record as a reference to a hash of (field name = field value)> pairs.
#Row numbers count from zero.
my $recordtohash = $dbf->fetchrow_hashref(0);
my $arrayref = $dbf->fetchrows_arrayref(1, 6);
print "$dbf\n";
for ($i = 0; $i <= 5; $i++) {
#Return a the title of the specified column. $i
# can be a column name or number.
#Column numbers count from zero.
my $nameofthecolumns = $dbf->fieldname($i);
#Return the dBASE field type for the specified column.
#$i can be a column name or number. Column numbers
#count from zero.
my $fieldtype = $dbf->fieldtype($i);
#Return the byte width for the specified column. $i
#can be a column name or number.
#Column numbers count from zero.
my $bytewidth = $dbf->fieldlength($i);
#print "Field $i is called: $nameofthecolumns the type is: ".
# "$fieldtype and his byte width is $bytewidth\n";
}
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4