Re: DBD::DBM and hashrefs



I've blabbered about this enough, here's some example code I ran just now.

The script:

----------start----------
use strict;
use warnings;

use DBI;
use Data::Dumper;

#Test of DBD::DBM with MLDBM
#MLDBM file format is $Dbm{ $id } = {key => $val, key2 => $val2 };

my $dbh = DBI->connect('dbi:DBM:mldbm=Storable;type=DB_File;f_dir=/home/sappy/public_html');
$dbh->{RaiseError} = 1;
$dbh->{dbm_store_metadata} = 0;

#Except for 'id', each column in dbm_cols corresponds
#to keys from the hashrefs in the MLDBM file
$dbh->{dbm_cols} = 'id,path,publication_name,regex_headlines';


my $statement = $dbh->prepare('SELECT
id,path,publication_name,regex_headlines FROM sites WHERE id=?');
$statement->execute('id_services-http-users-r-ryantate-cgi-bin-se_ho_admin-23362-1058765796-14\
70540404-3232250416');
my @row = $statement->fetchrow_array;
print Dumper(@row);

----------end----------

What I expected as output was an array of four defined, simple scalar
values, corresponding to $id ("id_services ..."), $Dbm{$id}{path}
("/index.html"), $Dbm{$id}{publication_name} ("Dude's Site"), etc.

What I got as output from this test script was $id, a hashref
comprising the entirety of $Dbm{$id}, and two undefined values. More
precisely:

----------start----------
$VAR1 = 'id_services-http-users-r-ryantate-cgi-bin-se_ho_admin-23362-1058765796-1470540404-323\
2250416';
$VAR2 = {
'match_join_exclude_target' => '',
'match_num_year' => [
'3'
],
'search_target_exact_phrase_atom_handling' => 'Match whole exact phrase',
---snip---
'path' => '/index.html',
---snip---
'publication_name' => 'Dude's Site',
---snip---
'regex_headlines' => '<h3>[A-Za-z]+?, ([A-Za-z]+?) (\\d\\d?),
(\\d\\d\\d\\d)</h3>\\s*<div cl\
ass="blogPost">\\s*(.{1,20})(.*?)\\s*<div class="byline">Posted by: <a
href="([^"]+)">',
'regex_exclude_list' => [],
'next_page_increment_flag' => ''
};
$VAR3 = undef;
$VAR4 = undef;
----------end----------

Short of patching the module, is there anything I can do to get what I expected?
.



Relevant Pages

  • Re: TERM::ReadLine and program flow question
    ... on the off chance that my 'default' sub turns up returning undef ... an undef value, which the sub converts to '' .. ... that's all fine and dandy but I don't want to make the user re-run the ... script several times whenever he supplies bad input. ...
    (perl.beginners)
  • Re: Clash between DBI/Oracle::DBD and SOAP::Lite
    ... Duncan Garland wrote: ... We've got a script which segmentation faults whenever we try to use both DBI and SOAP::Lite. ... 'HTTP::Request=HASH', undef, undef, undef, 180) called at ... *Perl Programmer* ...
    (perl.dbi.users)
  • Clash between DBI/Oracle::DBD and SOAP::Lite
    ... We've got a script which segmentation faults whenever we try to use both DBI and SOAP::Lite. ... 'HTTP::Request=HASH', undef, undef, undef, 180) called at ... When the call to connect to Oracle is commented out, ... *Perl Programmer* ...
    (perl.dbi.users)
  • Re: Missing documentation for HAVE_FOOBAR definitions
    ... I have a file config.h.in which contains a load #undef HAVE_FOO macros. ... config.h.in is created by autoheader. ... config.h is not generated directly by the configure script, ... "not a good idea" I mean it will cause frustration and possible ...
    (comp.os.linux.development.apps)
  • Re: DBD::CSV malfunction?
    ... Use of uninitialized value in concatenation or string at ... I tried your script and I agree, I can't quite seem to get it to work ... It seems to have an issue reading the column headings from ... 'escape_char' => undef, ...
    (comp.lang.perl.misc)