@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>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.