It looks like GetSegments returns an array ref. If so, then SegmentCount is superfluous, no?
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)
};
But even the index is unnecessary (unless you actually need the number for some reason):
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.