[ABE.pm] A better way?

Faber J. Fedor faber at linuxnj.com
Thu Oct 12 17:25:14 PDT 2006


I finally used a technique from HOP, in-line caching to be precise. I
was pleased with myself.  Here's a trimed down version of my code:

for ($i=0; $i <= $end; $i++) {

    if( !defined($captArray[$i])){
            generateException($cusipArray[$i]);
            next;
            }
    # do some useful stuff here
}

generateException('print_report');


{
    my @ListOfCusips ;

    sub generateException {

        ($cusip) = @_;

        if ($cusip eq "print_report") {
            magically_print_the_array_to_file(@ListOfCusips);
        } else {
            push @ListOfCusips, $cusip;
        }
        return(0);
    }
}


The only thing I don't like about this is my "overloading" of the argument
to generateException; at one point in the program the argument is a
cusip (think 'serial number') and at another point it's a directive.

Is there a more elegant way to do this?

What I'm attempting to do in the for loop is to catch any cusips that have undefined
value and write those cusips to file.


-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the ABE-pm mailing list