rd48sec has asked for the wisdom of the Perl Monks concerning the following question:
I am new to PERL. I am trying to create a loop to print out several text files created by the eslif switch. Each line from the input files are evaluated and then put in an array "bucket". I am trying to print out each array bucket with:
bias.txt has b40, b20, b80 x.txt has x40, x20, x80 y.txt has y40, y20, y80 z.txt has z40, z20, z80
Any suggestions are welcom. Thanks for looking
@ARGV = ("-40.txt", "+20.txt", "+80.txt");while (<>) { ($null,$x,$y,$z,$xb,$yb,$zb,$tp,$f1,$f2) = split m!\+|\-|\s\+|\s\- +|\s!; if ($f2 == undef){next;} #skip incomplete line elsif (($x<10) && ($y<10) && ($z<10)){ $axis[0] = "b";} # Bias elsif ($x>30){ $axis[1] = "x";} # X elsif ($y>30){ $axis[2] = "y";} # Y elsif ($z>30){ $axis[3] = "z";} # Z # Temperature if (($tp<45) && ($tp>35)){$temp[0] = 40; $output[@axis][@temp] .= +$_;} #-40 elsif (($tp<25) && ($tp>15)){$temp[1] = 20; $output[@axis][@temp] +.= $_;} #+20 elsif (($tp<85) && ($tp>75)){$temp[2] = 80; $output[@axis][@temp] +.= $_;} #+80 } @file = qw(bias.txt x.txt y.txt z.txt); foreach $filename (@file) { open $fh, '>', $filename; foreach $temp (@{$output[$temp]}) { print $fh $output[$temp][$axis], "\n"; } $axis++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing out an Array of an Array...
by poj (Abbot) on Feb 03, 2017 at 19:42 UTC | |
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 |