[ABE.pm] A better way?
Ricardo SIGNES
rjbs-perl-abe at lists.manxome.org
Thu Oct 12 18:44:33 PDT 2006
* "Faber J. Fedor" <faber at linuxnj.com> [2006-10-12T20:25:14]
> Is there a more elegant way to do this?
Well, I'm not exactly sure, but I think this will do what you want:
for my $i (0 .. $end) {
if ( !defined($captArray[$i])) {
generateException($cusipArray[$i]);
next;
}
# do some useful stuff here
}
print_exception_report;
{
my @ListOfCusips;
sub generateException {
($cusip) = @_;
push @ListOfCusips, $cusip;
}
sub print_exception_report {
magically_print_the_array_to_file(@ListOfCusips);
}
}
I'm not really sure what the point of all this is, though. Why not this:
my @ListOfCusips;
for my $i (0 .. $end) {
if ( !defined($captArray[$i])) {
push @ListOfCusips, $cusipArray[$i];
next;
}
# do some useful stuff here
}
print_report(\@ListOfCusips);
sub print_exception_report {
my $list = shift;
magically_print_the_array_to_file(@$list);
}
Also, the fact that you have two arrays with parallel indices really makes it
look like you want a hash.
--
rjbs
More information about the ABE-pm
mailing list