in reply to Strange GDBM behavior

I wrote a simple test writer and reader and did not have any problems.

Here is the writer.

#!/usr/bin/perl use GDBM_File; my %ports; tie(%ports,'GDBM_File','gdbmtest',&GDBM_NEWDB,0644) or die "$!\n"; for my $switch (0 .. 5) { for my $ifnum (0 .. 5) { $ports{"$switch:$ifnum"} = "test $switch $ifnum"; } } untie(%ports) or warn "$!\n";
And a reader
#!/usr/bin/perl use GDBM_File; my %ports; tie(%ports,'GDBM_File','gdbmtest',&GDBM_READER,0644) or die "$!\n"; for my $switch (0 .. 5) { for my $ifnum (0 .. 5) { print $ports{"$switch:$ifnum"}, "\n"; } } untie(%ports) or warn "$!\n";
-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re^2: Strange GDBM behavior
by wink (Scribe) on Jul 22, 2005 at 04:44 UTC
    Oddly enough, further examination of the file showed that there was one huge incomplete line after what I posted (vi didn't like showing it but emacs did). I was able to read from the file and get correct output. Why is it inserting that text from the module, though? Is that intended behavior? I actually created my reader script by copying the writer, and forgot to change the GDBM_NEWDB the first time... when I examined that produced file, it had the entire text of the reader script in it. Oh well... I suppose all's well that's read well.