in reply to Re^3: Storing/parsing perl data structure in/from a file
in thread Storing/parsing perl data structure in/from a file

As I feared (though it makes sense)

tied_hashes do it with list assignments (they are sequential) but not with ano-hash assignment (they are precompiled, hence collisions are optimized)

FWIW

use strict; use warnings; use Data::Dump qw/pp/; package HoA; require Tie::Hash; our @ISA = qw(Tie::StdHash); sub STORE { my ($this,$key,$value) =@_; push @{$this->{$key}}, $value; } package main; my $data_str= do { local $/;<DATA>}; tie my %h, "HoA"; my $h=\%h; %h = eval "$data_str"; pp $h; %h = eval "%{ { $data_str } }"; pp $h; __DATA__ ( alpha => 1, alpha => 2 )

shows

{ # tied HoA alpha => [1, 2], } { # tied HoA alpha => [2], }

Cheers Rolf

( addicted to the Perl Programming Language)