That's the nature of references. They refer to some other thing which exists somewhere else. If you copy just the reference (by pushing it onto the array), that copy will still refer to the same old thing.
You have to create a new data structure for each new set of info:
my ($title, $text, ...) = split /:/; push @a, { TITLE => $title, TEXT => $text, ... };
Also search CPAN for various modules that allow making deep copies of data structures.
In reply to Re: the ref use the same memory when i push structure onto array? Gahh .. please help me dear perl-gurus
by almut
in thread the ref use the same memory when i push structure onto array? Gahh .. please help me dear perl-gurus
by theantler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |