I would like to make an adjustment to this ternary operator. Instead of returning 0 if length( $dist ) is not > 1. I would like to return the last $dist value incremented by 0.1 mile so there is no gap of more than 0.1 miles.
$dist = sprintf "%.1f", ( length( $dist ) > 1 ) ? $dist/6.6/8/2*10/10 : 0 ; below is my full program: #!/usr/bin/perl use warnings; use strict; use POSIX; my $filepath = '/home/cstinemetz/perl_programs/1.EVDOPCMD'; my $runTime = sprintf("/cygdrive/c/temp/%s.txt",strftime("%y%m%d%H%M",localtime)); my $fileDate = strftime("%y%m%d%H%",localtime); open my $fh, '<', $filepath or die "ERROR opening $filepath: $!"; open my $out, '>', $runTime or die "ERROR opening $runTime: $!"; my $time = localtime; my %sum; while (<$fh>){ next unless /;/; chomp; my @data = split /;/; my($cell,$sect,$chan,$rlp1,$rlp2,$rlp3,$rlp4,$dist) = @data[31,32,38,44,45,46,47,261]; if( $cell >= 1 && $cell <= 900 && $sect >= 1 && $sect <= 6 ) { my $carr = ( $cell <= 299 && $chan == 175 ) ? 2 : ( $cell >= 300 && $cell <= 599 && $chan == 75 ) ? 2 : ( $chan == 1025 ) ? 2 : 1 ; #nested ternary operator $dist = sprintf "%.1f", ( length( $dist ) > 1 ) ? $dist/6.6/8/2*10/10 : 0 ; ##### would like to return increment of 0.1 if $dist < 1 ####### for my $i (44..47) { my $rlp = $data[$i]; $sum{$cell}{$sect}{$carr}{$dist} += $rlp if $rlp; } } } my @data; for my $cell ( sort keys %sum ) { for my $sect ( sort keys %{$sum{$cell}} ) { for my $carr ( sort keys %{$sum{$cell}{$sect}} ) { for my $dist ( sort keys %{$sum{$cell}{$sect}{$carr}} ) { push( @data, [ $sum{$cell}{$sect}{$carr}{$dist}, $cell, $sect, $carr, $dist,]); } } } } for my $record ( sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] || $a->[4] <=> $b->[4] } @data ) { my( $val, $cell, $sect, $carr, $dist ) = @$record; print $out "$time\t $cell\t $sect\t $carr\t $dist\t $val\n"; } close $out; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/