in reply to Re^2: Assign (key, value) to a hash w/o clobbering hash
in thread Assign (key, value) to a hash w/o clobbering hash

That's nasty :)

It's much simpler using Tie::StdHash as you only need to implement the methods that you want to override.

package Tie::Hash::ExpandingHash; use strict; use warnings; use Tie::Hash; our @ISA = 'Tie::StdHash'; sub CLEAR { } # NOT IMPLEMENTED sub FORCE_CLEAR { %{$_[0]} = () }
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^4: Assign (key, value) to a hash w/o clobbering hash
by reasonablekeith (Deacon) on Sep 28, 2006 at 11:47 UTC
    davorg, I did mention I tried to do it with Tie::StdHash :). It's obviously the way to go if one was to choose this method. However, I still can't get a working example going, even using your example above. For me it gives an error when I try to tie the hash...
    Can't locate object method "TIEHASH" via package ...
    the line being
    tie my %hash, 'ExpandingHash';
    and I also tried
    tie my %hash, 'Tie::Hash::ExpandingHash';

    ---
    my name's not Keith, and I'm not reasonable.