[Pdx-pm] Instance hash ( keyed array )

Roderick A. Anderson raanders at acm.org
Wed Oct 18 04:56:46 PDT 2006


I'm sorry I was so vague.  This method will used to do three things.

One get the calling script's data, two do the first level of formatting 
of the data for the next step in the processing and three make it 
slightly easier to determine how many records there are.

This is for s-mail address processing for bulk mail.  FWIW - Mailroom 
Toolkit (MRTK) by Satori Software.  I work for a custom mail-piece 
publishing company.  (http://www.bydesignpublishing.com/)

So here is the rest-of-the-story.

The data comes from an output file generate by another process from our 
database.  There will be other information, besides the address stuff, 
that is needed to build the mail piece.

So a sample line of data and a label/header line might look like this:

fname<TAB>lname<TAB>address_1<TAB>address_2<TAB>city<TAB>state<TAB>zip<TAB>\
image_1<TAB>greeting<NL>

George<TAB>Bush<TAB>1600 Pennsylvania 
Ave.<TAB><TAB>Washington<TAB>DC<TAB>20500<TAB>12345.jpg<TAB>Dear George,<NL>

The calling script reads in the file, splits out the address fields, 
passes those to the add_addr method, gets the $recid back.  The other 
fields ( fname,lname,image_1,greeting) are stored in %therest using 
$recid as the key.

After all the data is passed in, method(s) will do some MRTK setup, pass 
the, _preformated_, values to the MRTK, which will certify and 
Postalsort the addresses.

The _ordered_ returned data, with the included $recid, will be used to 
build a new file from itself and %therest.

This file is then used to build the press files.

I now see that $self->{addr_data} doesn't have to be a hash.  An array 
will work since, as observed, I already have the $recid in the string.

Shorted story is ... Thanks.  All your comments and suggestions helped 
me clarify what I need to do.


Rod
-- 
Roderick A. Anderson wrote:
> I'm working on a module [0] that needs to do something I have not seen 
> in any other module or documentation.  It may be my ignorance that is 
> making this complicated.
> 
> I need to build a, sometimes, quite large hash table ( 40,000 - 470,000 
> records ) one record at a time.  The method will return the key it is 
> used to the caller so it can be used to key the rest of the data not 
> passed in to the method.
> 
> Here is the sub.
> 
> sub add_addr {
> 
>      my $self = shift;
>      my @stuff = @_;
> 
>      my $recid = $self->inc_recid();
>      my $addr = join( $FldDelim, $recid, @stuff );
>      $addr .= $RcdDelim;
> 
>      $self->{addr_data}->{$recid} = $addr;
> 
>      return $recid;
> }
> 
> Is there a better way to do this?
> 
> [0] actually re-working a script into a module.
> 
> 
> Thanks for any insights or ideas,
> Rod



More information about the Pdx-pm-list mailing list