in reply to My first package - need help getting started
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/..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: My first package - need help getting started
by Limbic~Region (Chancellor) on Feb 27, 2003 at 04:28 UTC |