Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I've created an array of anonymous hashes
to act as structures to hold data from some files
I'm working on parsing.
For various reasons, I need to add an element
into the middle of the array that is the same
as the one before it except for some minor
modifications.
I'd been doing this with:
(Side question: When using splice and replacing a run of 0 length, are new elements put at the offset position, or after?)
Thanks in advance, wise Monks.
Of course, I've noticed that this just makes $new_element a reference to the same anonymous hash. What is the best way to make $new_element be a reference to an anonymous hash with the same data as the anonymous hash in $hash_array$index, so that I may splice it in?my $new_element = $hash_array[$index];
(Side question: When using splice and replacing a run of 0 length, are new elements put at the offset position, or after?)
Thanks in advance, wise Monks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Copy of an anonymous hash?
by holli (Abbot) on Apr 26, 2005 at 07:33 UTC | |
by DrHyde (Prior) on Apr 26, 2005 at 09:37 UTC | |
by tphyahoo (Vicar) on Apr 26, 2005 at 14:16 UTC | |
by Fletch (Bishop) on Apr 26, 2005 at 15:04 UTC | |
Re: Copy of an anonymous hash?
by pelagic (Priest) on Apr 26, 2005 at 11:42 UTC | |
by salva (Canon) on Apr 26, 2005 at 12:18 UTC | |
by pelagic (Priest) on Apr 26, 2005 at 12:29 UTC | |
by ambrus (Abbot) on Apr 26, 2005 at 19:47 UTC |
Back to
Seekers of Perl Wisdom