http://qs321.pair.com?node_id=11127505

GrandFather has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a module for parsing and extracting data out of ELF (Executable and Linkable Format) files which I intend to put on CPAN shortly. An ELF file contains a couple of important tables whose entries describe parts of the file (segments and sections). I have an object which holds on to objects for each of the tables. The tables aren't very interesting, but the table entries are so I want to provide access to the individual entries. Current options look like this:

use warnings; use strict; use ELF::Reader; my $elfPath = $ARGV[1]; my $elfFile = ELF::Reader->new(filePath => $elfPath); # Using index on the segments object my $segments = $elfFile->GetSegments(); for my $segIndex (0 .. $elfFile->SegmentCount() - 1) { next if !${$segments}[$segIndex]->FileSize(); print ${$segments}[$segIndex]->Describe(head => 16, tail => 16, wi +dth => 32) }; print "\n"; # Using an iterator my $nextSeg = $elfFile->GetSegmentIter(); while (my $segment = $nextSeg->()) { next if !$segment->FileSize(); print $segment->Describe(head => 16, tail => 16, width => 32) }

Prints:

Type: PT_LOAD Virtual load address: 0x00000000 Memory image size: 0x000129f8 Segment alignment: 0x00000008 00000000: 20040000 00010019 00010069 00010081 000129e8: 000129c8 60200000 000129d0 20000000 Type: PT_LOAD Virtual load address: 0x00000000 Memory image size: 0x000129f8 Segment alignment: 0x00000008 00000000: 20040000 00010019 00010069 00010081 000129e8: 000129c8 60200000 000129d0 20000000

The question is: should I provide both access techniques, or just one (which?) or something else? There will be a number of different classes that provide similar acessors.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond