another non-OO way of doing things popped into my head. theres a module for processing NetFlow records ( module CFlow out of the flow-tools package, not on CPAN ) that does things like this:

sub match_func { return 0 unless $bytes > 5000; return 0 unless $src_port == 80; # do_something with matched return 1; } CFlow::loop( \&match_func, $filehandle ); print "matched $CFlow::match_count records\n";

since you generally work with a single record, if the fields of the record are unique... forget all of the OO stuff and use globals. the 'loop' routine takes a coderef to be run after each record is parsed (and shoved into the global variables) and a filehandle ( if filehandle is undef, read STDIN, if filehandle is a string, open and use that file.). the coderef returns 0 if the record wasn't interesting, else it does whatever and returns 1 (so the module can keep track of how many records matched).

while not-00, it does do an excellent job of hiding the details from the user, eliminates all of the derefrencing ( $chunk->type() just becomes $type) which makes it easy to write quick one-off scripts.

sub fix_building { return 0 unless $building eq 'FOO'; $building eq 'BAR'; print_rec; return 1; } DBParserThingy::loop ( \&fix_building );

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.