Re: multidimensional insertion order
- From: xhoster@xxxxxxxxx
- Date: 28 Jul 2005 22:20:30 GMT
Spin <cNaOlSePbA@xxxxxxxxxxxxxxxxxx> wrote:
> Paul Lalli wrote:
> > You're attempting to tie a reference to a hash to the Tie::IxHash
> > class. A reference is a scalar. Therefore, tie() is attempting to use
> > a non-existant TIESCALAR method.
> >
> > You *want* to tie the hash that that reference references to the
> > Tie::IxHash class.
> >
> > Try: (untested)
> >
> > tie %{$xml_lines{$section}->{$section_number}}, "Tie::IxHash";
> >
> >
> That truncates the hash somehow.
When you tie a hash to Tie::IxHash, it empties the hash (which makes sense,
as what else is it going to do with pre-existing, and hence generally
unordered, data?).
You are retying the hash each time through the loop, and so re-emptying it
each time and are left only with the last thing inserted. You want to
detect whether the subhash already exists and then create and tie it only
if it doesn't already exist.
unless ($xml_lines{$section}->{$section_number}) {
tie %{$xml_lines{$section}->{$section_number}}, "Tie::IxHash";
};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.
- References:
- multidimensional insertion order
- From: Spin
- Re: multidimensional insertion order
- From: Abigail
- Re: multidimensional insertion order
- From: Spin
- Re: multidimensional insertion order
- From: Paul Lalli
- Re: multidimensional insertion order
- From: Spin
- Re: multidimensional insertion order
- From: Paul Lalli
- Re: multidimensional insertion order
- From: Spin
- Re: multidimensional insertion order
- From: Paul Lalli
- Re: multidimensional insertion order
- From: Spin
- multidimensional insertion order
- Prev by Date: DBI MySQL Use Another DB Without Disconnecting
- Next by Date: Re: multidimensional insertion order
- Previous by thread: Re: multidimensional insertion order
- Next by thread: Re: multidimensional insertion order
- Index(es):
Relevant Pages
|