Thanks, all who replied. However, I forgot something while trying to narrow it down. One of the hashes is a tie()d array, and that's what goes wrong for some reason.

So much for trying to find out where it goes wrong. Here's the real script:
2;0 juerd@ouranos:~$ rm karmatest 2;0 juerd@ouranos:~$ perl test.pl Use of uninitialized value in addition (+) at test.pl line 31. 2;0 juerd@ouranos:~$ cat test.pl #!/usr/bin/perl -w package Karma; use GDBM_File; use strict; sub new($$){ my ($prot, $file) = @_; my $self = { hash => {} }; $self->{object} = tie %{ $self->{hash} }, 'GDBM_File', $file, GDBM +_WRCREAT, 0640; bless $self, $prot; return $self; } sub resolve($$){ my ($self, $subject) = @_; $subject = lc $subject; my $recur = 0; if (defined $self->{hash}{$subject}){ while ($self->{hash}{$subject} =~ /^S:(.*)/){ $subject = 'ERECURSIE', last if ++$recur > 10; $subject = lc $1; } } # The next line was put in to work around the warning. # $self->{hash}{$subject} = 0 unless defined $self->{hash}{$subject} +; return \ $self->{hash}{$subject}; } sub incr($$;$){ my ($self, $subject, $d) = @_; #line 31 return ${ $self->resolve($subject) } += defined($d) ? $d : 1; } sub decr($$;$){ my ($self, $subject, $d) = @_; return ${ $self->resolve($subject) } -= defined($d) ? $d : 1; } sub get($$){ my ($self, $subject) = @_; my $foo = ${ $self->resolve($subject) }; print "BLAAT: $foo\n"; return $foo; } sub set($$$){ my ($self, $subject, $new) = @_; return ${ $self->resolve($subject) } = $new; } sub reorganize($){ $_[0]->{object}->reorganize(); } 1; package main; my $karma = Karma->new('karmatest'); $karma->incr('foo'); # foo must not exist

I'm sorry to have disappointed you by leaving out a very important part.

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$


In reply to Re: Autovivification not working? by Juerd
in thread Autovivification not working? by Juerd

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.