Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

RE: (Guildenstern) REx3: Array mysteriously disappears on loop exit...

by Anonymous Monk
on Oct 09, 2000 at 20:14 UTC ( [id://35934]=note: print w/replies, xml ) Need Help??


in reply to (Guildenstern) REx3: Array mysteriously disappears on loop exit...
in thread Array mysteriously disappears on loop exit...

@containeeArray is a hash of hashes containing references to the same kind of hashes as in @containerRefArray. After I get the index of the container containing %$object, in following code I look up the corresponding entry in @containeeArray. I then sort the hash in $containeeArray$i and then return the position in this sortted hash of %$object.

That was the plan anyway.

Here's the rest of the fns

<CODE> sub sort_objects { $a->{'~entPhysicalIndex'} <=> $b->{'~entPhysicalIndex'}; } sub get_parentRelPos (\%$) { my ($object, $name)=@_; my ($i, $j, $found); my (@tmp, $dummy); my $parentObject=$object->{'~PARENT'}; my $objectIndex=$object->{'~entPhysicalIndex'}; if (ref $parentObject ne 'HASH') { confess "parent object wasn't a hash"; return -1; } for ($i=0; $i < @containerRefArray; $i++) { if ($containerRefArray$i eq $parentObject) { $found=1; last; } } if ($found) { # Call the code in each contained object to obtain the entPhysicalIndex of each one and then sort them (references in containeeArray point to tied hashes) # 1: # sorting with sort sort_objects @{$containeeArray$i} didn't work for some reason ?? # 2: # @tmp=@{$containeeArray$i}; # 3: # foreach $dummy (@{containeeArray$i}) { # push @tmp, $dummy; # } # none of the above 3 methods seem to work right @tmp = sort sort_objects @tmp; for ($j=0; $j < @tmp; $j++) { if ($tmp$j eq $object) { return $j+1; } } } return -1; } <\CODE>
  • Comment on RE: (Guildenstern) REx3: Array mysteriously disappears on loop exit...

Replies are listed 'Best First'.
(Guildenstern) REx5: Array mysteriously disappears on loop exit...
by Guildenstern (Deacon) on Oct 09, 2000 at 22:25 UTC
    Okay. I'm pretty sure I haven't found out why yuor array is empty. I did notice some other stuff in your code and explanation.
    Are you sure @containeeArray is a hash of hashes? It looks more to me like it's an array of hashrefs.
    # sorting with sort sort_objects @{$containeeArray$i} didn't work for some reason ??Not sure here, but it seems to me like the value if $i may not be what you think it is. Plus, if @containeeArray really is an array of hashrefs, this code shouldn't work. I would try something like sort sort_objects @containeeArray instead.

    Guildenstern
    Negaterd character class uber alles!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://35934]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-20 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found