The Profile Engine (part 2)

The second half of the engine handles the cases where we select individual operators to appear in the output.

  # but if arguments are provided, handle them properly:
  # make sure argument is actually in the database
  else {
    push(@sought, $_) foreach (sort keys %data);
    # if we're just displaying results on screen ...
    if (! $write) {
      foreach (@sought) {
        defined $data{$_}
          ? $self->_profile_subengine(\%data, $_)
          : print "$_ not found.\n\n";
      }
    }

    # but if we're writing to file(s) (one file per element) ...
    else {
      foreach (@sought) {
        if (defined $data{$_}) {
          my $output = $_ . '.txt';
          my $oldfh = select OUT;
          open OUT, ">$output" or die;
          $self->_profile_subengine(\%data, $_);
          close OUT or die;
          select($oldfh);
        } else {
          print "$_ not found.\n\n";
        }
      }
    }
  }

Previous Back to start of show Next
Slide: 23 prof_eng_2 © 2003 James E. Keenan