[ABE.pm] A question
Ted Fiedler
fiedlert at gmail.com
Mon May 7 12:06:13 PDT 2007
Perhaps a stupid one...
I have a block of about 30 if statements such as
my %HASH;
for my $id(@transactions)
{
my $action;
if ( $x ne "NULL" )
{
# $x and x are always the same
$HASH{$id}{'x'} = $x;
$action ++;
}
if ( $y ne "NULL" )
{
$HASH{$id}{'y'} = $y;
$action++;
}
#### snipping about 28 other ifs ####
if ($action)
{
# do something
}
}
Id like to shorten the cluster of ifs with something like
for my $id(@transactions)
{
my $action;
for my $ref (@listofrefs)
{
$HASH{$id}{'ref'} = $ref
if ( $ref ne "NULL" )
$action++;
}
if ( $action )
{
# do something...
}
}
I know ive done this or something like it before, I just cant find
the code...
Ted
--
"You are never dedicated to something you have complete confidence in. No
one is fanatically shouting that the sun is going to rise tomorrow. They
know it's going to rise tomorrow. "
-- Robert M Pirsig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070507/9a72cc27/attachment-0001.html
More information about the ABE-pm
mailing list