[ABE.pm] A question

Ricardo SIGNES rjbs-perl-abe at lists.manxome.org
Mon May 7 13:03:48 PDT 2007


* Ted Fiedler <fiedlert at gmail.com> [2007-05-07T15:06:13]
> for my $id(@transactions)
> {
> 
>    my $action;
>    for my $ref (@listofrefs)
>    {
>        $HASH{$id}{'ref'} = $ref
>            if ( $ref ne "NULL" )
>        $action++;
>    }
> 
>    if ( $action )
>    {
>        # do something...
>    }
> }

There are two problems here, at least:

  1. "ref" is really generic and I can't tell what it means in each case
  2. you're using $ref and "ref" which scares me and makes me think that you
     want to use symbolic references, which suck

This is my guess at the real problem: you want to fill in defaults into rows.

  my %default = (
    color  => 'red',
    flavor => 'cod',
  );

  for my $id (@transactions) {
    my $actions_taken = 0;

    DEFAULT: for my $key (keys %default) {
      next DEFAULT if $default{ $key } eq 'NULL';
      $HASH{ $id }{ $key } = $default{ $key };
      $actions_taken++;
    }
  }

...or something like that.

-- 
rjbs


More information about the ABE-pm mailing list