in reply to Index or iterate - your choice
It looks like GetSegments returns an array ref. If so, then SegmentCount is superfluous, no?
But even the index is unnecessary (unless you actually need the number for some reason):my $segments = $elfFile->GetSegments(); for my $segIndex (0 .. #$segments) { $segments->[$segIndex]->FileSize() or next; print $segments->[$segIndex]->Describe(head => 16, tail => 16, wid +th => 32) };
print $_->Describe(head => 16, tail => 16, width => 32) for grep $_->FileSize, @$segments;
If GetSegments doesn't in fact return an array ref, then make a method that does. :-) It could even be a tied array for more perlishness.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Index or iterate - your choice
by GrandFather (Saint) on Jan 27, 2021 at 21:14 UTC |