I am trying to return new values based on if else. I understand the idea of 
using if else, but I am not sure I have placed in the right place.
I was assuming I would want to insert it before the array is sorted.
Thank you in advance. This mailing list is helping me understand perl greatly!

I am getting the following error:
Use of uninitialized value within @data in pattern match (m//) at ./DOband.pl 
line 19, <$fh> line 485.


#!/usr/bin/perl

use warnings;
use strict;

my $filepath = 'C:/temp/PCMD';
my $outfile  = 'output.txt';

open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
open my $out, '>', $outfile or die "ERROR opening $outfile: $!";

my @array;

while (<$fh>) {
                next unless /;/;
    chomp;
    my @data = ( split /;/ )[31,32,38,39,261];

                if (@data[39] =~ /15/)
                {
                2
                }
                else
                {
                1
                }

    push @array, join "\t", @data;
}

@array = sort {
  my @aa = split /\t/, $a;
  my @bb = split /\t/, $b;
  $aa[0] <=> $bb[0] or
  $aa[1] <=> $bb[1] or
  $aa[2] <=> $bb[2];
} @array;

print $out "$_\n" foreach @array;
close $out;




#RTD 1 unit = 4 chips RUM Field 16 0 - 2^16 - 1 milliseconds








Chris Stinemetz

Reply via email to