Greetings.

Is it possible to reference a control operator?

For example, I'd like to take this code:


   sub getFieldFromAllRecords {
   my ($self, $directive, $keyword, $matchCondition) = @_;
 
        my ($field, $regArr);
 
        # another public method within same pkg:
        my $allRecs = dumpAllAudits($self);
        my %ar = %$allRecs;
 
        push @{$regArr}, qr/$keyword/i;
 
        my %select;
        while( my($key, $value) = each(%ar)) {
             map { next unless ($$value{$directive} =~ /$_/i); } @{$regArr};
             $select{$key} = $$value{$directive};
        }
 
   return \%select;
   }

and change it such that the 'unless' conditional operator is
referenced conceptually similar to the following:

   sub getFieldFromAllRecords {
   my ($self, $directive, $keyword, $matchCondition) = @_;
 
        my $mc = $matchCondition;  # changed: where $mc can be either
                                   # 'if' or 'unless'.
        my ($field, $regArr);

        # another public method within same pkg:
        my $allRecs = dumpAllAudits($self);
        my %ar = %$allRecs;
 
        push @{$regArr}, qr/$keyword/i;
 
        my %select;
        while( my($key, $value) = each(%ar)) {
             map { next $mc ($$value{$directive} =~ /$_/i); }   # changed
                 @{$regArr};
             $select{$key} = $$value{$directive};
        }
 
   return \%select;
   }
 
If it's not possible to reference operators, I'll rework the code.

Thanks in advance.
jab

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to