wink has asked for the wisdom of the Perl Monks concerning the following question:
Hey, I'm new to PM and this is my first post. I'm also *fairly* new to Perl, but I do have a bit of experience under my belt.
I have a script that is converting a text file into a database. I wanted to use GDBM because of its "many-reader" aspect. I'm beginning to think it's not worth it, but I was curious about why I'm getting what I'm getting.
It appears as though the database file itself is full of code from the XSLoader module. First, here's the script:
#!/usr/local/stow/perl-5.6.1/bin/perl -w use GDBM_File; my $portlist = "/dfs/umaint/stow/UMno/libdata/portlist"; my %ports; tie(%ports,'GDBM_File','gdbmtest',&GDBM_NEWDB,0644) or die "$!\n"; open(PL, $portlist) or die "$!\n"; while(<PL>) { chomp; next if(/^\#/ || $_ eq ""); my ($switch,$ifnum,$trunk,$desc) = split(/:/); my ($generated,$conn,$notes) = split(/\s(\+|-|!)\s*/,$desc); my ($ifname,$vlan,$host) = split(/\s/,$generated); $ports{"$switch:$ifnum"} = "$trunk:$ifname:$vlan:$host:$conn:$note +s"; } untie(%ports) or warn "$!\n";
And now for the gdbmtest file:
^SW\232\316^D^D^D^H^D0^BXzr.pm. # Often these errors are actually occurring in the initialisation # C code of the extension XS file. Perl reports the error as being # in this perl code simply because this was the last perl code # it executed. + my $libref = dl_load_file($file, 0) or do { require Carp; Carp::croak("Can't load '$file' for module $module: " . dl_err +or()); }; push(@dl_librefs,$libref); # record loaded object + my @unresolved = dl_undef_symbols(); if (@unresolved) { require Carp; Carp::carp("Undefined symbols present after loading $file: @un +resolved\n"); } + my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do { require Carp; Carp::croak("Can't find '$bootname' symbol in $file\n"); }; + my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, + $file); push(@dl_modules, $module); # record loaded module # See comment block above return &$xs(@_); retry: require DynaLoader;
When I used regular dbm(open|close) to create the database I was able to write to it and read from it correctly. I couldn't find anything odd with the GDBM_File.pm or XSLoader.pm files, but I could be missing something. Should I post the text of those files as well?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange GDBM behavior
by gam3 (Curate) on Jul 22, 2005 at 03:55 UTC | |
by wink (Scribe) on Jul 22, 2005 at 04:44 UTC | |
|
Re: Strange GDBM behavior
by graff (Chancellor) on Jul 22, 2005 at 05:01 UTC | |
by wink (Scribe) on Jul 22, 2005 at 05:14 UTC |