
my %h;
my $result = {a => 'I LIKE PIE'};

sub T::TIEHASH { 
  my ($pack) = @_;
  my $self = "Dummy";
  bless \$self => 'T';
}

sub T::FETCH {
  my ($self, $n) = @_;
  my $rv = $n ? $h{$n-1} : $result ;
  $rv;
}

tie %h, 'T';

# This works
print "With temporary variable:\n";
my $q = $h{1};
print "$q, $result ", $q->{a}, "\n";

# This does not
print "Without temporary variable:\n";
print $h{1}->{a}, "\n";
