my %hash; tie %hash, 'main'; $hash{'test'} = bless [], 'Test'; #### $hash{'test'} += 3; #### my $test = bless [], 'Test'; $test += 3; my %hash; tie %hash, 'main'; $hash{'test'} = bless [], 'Test'; $hash{'test'} = $hash{'test'} + 3; #### #!/usr/bin/env perl package Test; use overload '+' => \&append; sub append { my ( $self, $value ) = @_; push @$self, $value; return $self; } package main; use strict; use warnings; use Test::More tests => 14; use Test::Exception; sub TIEHASH { my ( $class ) = @_; return bless {}, $class; } sub FETCH { my ( $self, $key ) = @_; return $self->{$key}; } sub STORE { my ( $self, $key, $value ) = @_; $self->{$key} = $value; } lives_ok { my %hash; tie %hash, __PACKAGE__; $hash{'test'} = bless [], 'Test'; isa_ok($hash{'test'}, 'Test'); }; lives_ok { my %hash; tie %hash, __PACKAGE__; my $test = bless [], 'Test'; $test += 3; $hash{'test'} = $test; is(3, $hash{'test'}[0]); }; lives_ok { my %hash; tie %hash, __PACKAGE__; $hash{'test'} = bless [], 'Test'; $hash{'test'} = $hash{'test'} + 3; is(3, $hash{'test'}[0]); }; lives_ok { my %hash; tie %hash, __PACKAGE__; $hash{'test'} = bless [], 'Test'; my $test = $hash{'test'}; $test += 3; $hash{'test'} = $test; is(3, $hash{'test'}[0]); }; lives_ok { my %hash; $hash{'test'} = bless [], 'Test'; $hash{'test'} += 3; is(3, $hash{'test'}[0]); }; lives_ok { my %hash; tie %hash, __PACKAGE__; $hash{'test'} = []; push @{$hash{'test'}}, 3; is(3, $hash{'test'}[0]); }; lives_ok { my %hash; tie %hash, __PACKAGE__; $hash{'test'} = bless [], 'Test'; $hash{'test'} += 3; is(3, $hash{'test'}[0]); }; # ???