yes, an object for your chunk-o-data. but if your stream-o-data isn't likely to change i would say no object for the parser.

just have your object's creation method take a whole chunk-o-data.

package ChunkOData; sub from { my ($class, $chunk) = @_; $chunk =~ s/\n\t//g; # continuation lines are easy # parse $chunk like you already know how # shove it into a hash return bless \%self, $class; } # write some accessors # write some common useful junk package main; local $/ = ''; while (my $chunk_text = <>) { my $chunk = ChunkOData->from $chunk_text; next unless $chunk->type eq 'UR'; $chunk->owner('me'); if ($chunk->is_a_certain_type) { $chunk->do_some_standard_thing; $chunk->do_something_else($with_my_info); subroutines_are_good($chunk); } $chunk->print; }

if your stream-o-data is blank-line seperated (or other $/ -able format) this is a simple way to get started.

you might also use one of the Order-keeping Hash modules from the CPAN in an object for your key field. then you could do something like:

my $key = $chunk->key; next unless $key{OU} eq 'VALUE1'; my $otherkey = $chunk->key_as_string; # X=foo/Y=bar/..

In reply to Re: My first package - need help getting started by zengargoyle
in thread My first package - need help getting started by Limbic~Region

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.