[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] DBM file problems



At 11:53 AM -0400 4/10/00, Chris Nandor wrote:
>At 19.44 -0700 2000.04.09, Brian L. Matthews wrote:
>>Consider:
>>
>>#!/usr/bin/perl --
>>
>>use strict;
>>
>>use DB_File;
>>use Fcntl;
>>
>>my %dbm;
>>
>>tie %dbm, 'DB_File', 'illustrations', O_RDWR | O_CREAT, 0644 or
>>	die $0, ": can't create new DBM file: $!\n";
>>
>>$dbm{'abc'} = 0;
>>
>>my @keys = keys %dbm;
>>
>>print "number of keys = ", scalar (@keys), "\n";
>>print "length of first key = ", length ($keys[0]), "\n";
>>__END__
>>
>>The first time I run this on my G4 running OS 9.0.4 and the last
>>released PPC MacPerl, it (correctly) prints the number of keys as 1,
>>but prints the length of the first keys as 196611. If I run it again,
>>MacPerl crashes with a type 2 error.
>>
>>While I haven't tried the above on another machine, it's pared down
>>from a script that has worked fine on an 840AV and a 6100 for years,
>>but won't run on my G4, crashing MacPerl when appending to an element
>>of a hash tied to a DB_File file.
>
>Odd.  I have a similar problem, also on Mac OS 9.0.4.  I will have to try
>debugging later.  I get:
>
>   number of keys = 1
>   length of first key = 65539
>
>Then MacPerl dies after running it another time or two.  I don't know why
>the key is reported as being so long.  I have not seen anything like this
>before, but cannot attribute it to Mac OS 9.0.4, because I also recently
>changed my hard drive, and recall DB_File having certain problems with
>certain hard drive formatting things.

Interesting. Note that 65539 = 2**16 + 3 and 196611 = 3 * 2**16 + 3. 
I don't know if that means anything or not, but it seems unlikely to 
just be a coincidence. Also, I just copied the script to an HFS 
formatted volume (it was on my startup volume, which of course is 
HFS+), and it works fine. Prints the right key length, and I can run 
it any number of times (presumably, I quit at 10 :-)) without MacPerl 
crashing. It looks like DB_File has a problem with HFS+ volumes.

Brian

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org