Kevin Horton <mailto:[EMAIL PROTECTED]> wrote:

: My working prototype script with the hard-coded list of
: variables prints output with the following line:
:
: print OUTPUT
: "$data_time\t$TACH\t$MP\t$FUEL_FLOW\t$QTY\t$CHT1\t$CHT2\t$CHT3
: \t$CHT4\t$
: EGT1\t$EGT2\t$EGT3\t$EGT4\t$OILT\t$OILP\t$VOLT\t$OAT\t$UNIT_TEMP\n";

    I'd use a hash to store the log data. The report fields
would dictate the order of the data using a hash slice. Look
at the script below.

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


#!/usr/bin/perl

use strict;
use warnings;

# Dummy log data.
my %log_data = (
      data_time =>  1,
      TACH      =>  2,
      MP        =>  3,
      FUEL_FLOW =>  4,
      QTY       =>  5,
      CHT1      =>  6,
      CHT2      =>  7,
      CHT3      =>  8,
      CHT4      =>  9,
      EGT1      => 10,
      EGT2      => 11,
      EGT3      => 12,
      EGT4      => 13,
      OILT      => 14,
      OILP      => 15,
      VOLT      => 16,
      UNIT_TEMP => 18,
      OAT       => 17,
);

# Get fields from config.
my @report_fields = report_fields( 'log_data.cfg' );

# Use defaults if no configured fields.
@report_fields = qw(
                data_time TACH MP FUEL_FLOW QTY
                CHT1 CHT2 CHT3 CHT4
                EGT1 EGT2 EGT3 EGT4
                OILT OILP VOLT OAT
                UNIT_TEMP
            )
        unless @report_fields;

print join( "\t", @log_data{ @report_fields } ), "\n";

sub report_fields {
    # Dummy result to make this work.
    chomp( my @config = <DATA> );
    return @config;
}

__END__
data_time
TACH
FUEL_FLOW


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.3 - Release Date: 1/31/2005
 


-- 
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