in reply to Re: Looking for a good way to split a file into equal sized arrays
in thread Looking for a good way to split a file into equal sized arrays
In each case I can take the line and set it to some variable depending on which place in the field I want,{{{vars}}} my $infile = <STDIN>; print"Your input file is $infile\n\n"; open (INFILE, "<$infile")||die "no such file"; while (<INFILE>) { @data = <INFILE>; for ($x = 0; $x<=$#data; $x++){ chomp ($data[$x]); switch ($data[$x]){ # If start of section, increment array by 3 to skip header # case /^Begin Targets/ { $x += 3; } case /^0 / { # do not want last; } case /^1 / { @line = split(/ /,$data[$x]); # Get data out last; } case /^2 / { @line = split(/ /,$data[$x]); # Get data out last; } case /^3 / { @line = split(/ /,$data[$x]); # Get data out last; } # end case3 } # end switch } # end for } #end
...etc$DistX[$x] = $line[2]; $DistY[$x] = $line[3];
|
|---|