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?


In reply to Strange GDBM behavior by wink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.