Re: length of an array in a struct in an array of structs in a struct in an array of structs





Paul Lalli wrote:
> Billy N. Patton wrote:
> > Tuan Bui wrote:
> > > Hello,
> > >
> > > So I have this complex data structure I've built for myself, and I'm
> > > trying to get this snippet to work:
> > >
> > > $k <
> > > scalar(@{@{@VisitArray[$i]->PSearchStructArray[$j]->ClickPathArray}})
> > >
> >
> > Ths should do it.
> > $l=scalar(@{$VisitArray[$i]->PSearchStructArray[$j]->ClickPathArray});
>
> Just to be pedantic, the scalar keyword and its parentheses are no-ops
> there. The assignment to a scalar variable already imposes scalar
> context on the array.

Yeah, I'm a perl newbie and I'm using the constructs the llama tells me
to use :)

>
> Assuming the above does what you want,
>
> $l = @{$VisitArray[$i]->PSearchStructArray[$j]->ClickPathArray};
>
> should work just as well.

If by "just as well" you mean "syntax error," then yes :) It's one of
the first things I tried.

I'm pursuing the intermediate-step path right now:

my @PSARef = @{$VisitArray[$i]->PSearchStructArray};
for(my $k = 0; $k < scalar(@{$PSARef[$j]->ClickPathArray}); $k++) {

but for some reason it's returning abnormal lengths that are invariant
with different iterations of the innermost loop.

>
> Paul Lalli

Back to the grind,
Tuan

.



Relevant Pages