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

In reply to Index or iterate - your choice by GrandFather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.