in reply to Printing out an Array of an Array...
Can you provide a sample of the input date and explain what the output should be. In the meantime this is my guess at what you are trying to achieve.
poj#!perl use strict; my $axis; my %output; while (<DATA>){ my ($null,$x,$y,$z,$xb,$yb,$zb,$tp,$f1,$f2) = split ',',$_; next unless defined($f2) ; #skip incomplete line if (($x<10) && ($y<10) && ($z<10)){ $axis = 'bias'; } # Bias elsif ($x>30){ $axis = "x"; } # X elsif ($y>30){ $axis = "y"; } # Y elsif ($z>30){ $axis = "z"; } # Z else { next; } # Temperature if (($tp<45) && ($tp>35)){ $output{$axis}{40} .= $_; } #-40 elsif (($tp<25) && ($tp>15)){ $output{$axis}{20} .= $_; } #+20 elsif (($tp<85) && ($tp>75)){ $output{$axis}{80} .= $_; } #+80 } foreach my $axis (sort keys %output) { open my $fh, '>', $axis.'.txt'; print "Creating $axis.txt \n"; foreach my $temp (sort keys %{$output{$axis}}) { print $fh $output{$axis}{$temp}; } } #$null,$x,$y,$z,$xb,$yb,$zb,$tp,$f1,$f2 __DATA__ ,1,2,3,4,5,6,21,8,9 ,31,2,3,4,5,6,22,8,9 ,1,32,3,4,5,6,23,8,9 ,1,2,33,4,5,6,24,8,9 ,1,2,3,4,5,6,41,8,9 ,31,2,3,4,5,6,42,8,9 ,1,32,3,4,5,6,43,8,9 ,1,2,33,4,5,6,44,8,9 ,1,2,3,4,5,6,81,8,9 ,31,2,3,4,5,6,82,8,9 ,1,32,3,4,5,6,83,8,9 ,1,2,33,4,5,6,84,8,9
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing out an Array of an Array...
by rd48sec (Novice) on Feb 03, 2017 at 20:38 UTC | |
by poj (Abbot) on Feb 03, 2017 at 20:45 UTC | |
by rd48sec (Novice) on Feb 03, 2017 at 21:00 UTC |