Hello.
I am a new Perl user (not a student but research staff) and I'm trying to write a Perl program to manipulate some data files. I've used the split commands before to manipulate columns and rows but this is not working for my current need.
I have a program that outputs data in one continous column. For example if I have the program run two simulations (each containing 1000 data values), the program output is one continous column of 2000 data values.
What I am trying to do is have the Perl program generate 2 text files for each simulation each containing their respective column of 1000 data values.
The actual simulations I'm running contain over 500,000 data values each, so I need a perl script to handle it.
Many thanks for any help you can provide. The beginnings of the program I'm writing is below.
#!/usr/bin/perl -w
#Program reads GSLIB simulation output (continuous column of numbers) and writes individual
#output files for a user-defined number of GSLIB realizations
#
#GSLIB program outputs multiple realizations in a single continous column of data values.
#For example, if one realization contains 1000 data values and GSLIB is set to run 2 simulations,
#the output (*.txt file) will contain a continuous column of 2000 data values.
#What I'm trying to do is allow myself to enter the number of realizations (realiz) and the number
#of data values for each realization (size) and have the program output separate text files for
#each realization
@ARGV ++ 3 or die "Usage: extract.pl realiz size [in.file]\n";
$realiz = $ARGV[0];
$size = $ARGV[1];
$InFile = $ARGV[2];
# Open the input file (or die trying)
open(INPUT,"<$InFile") or die "Can't open file \"$file\".\n";
#loop through the file; start printing when
while (<INPUT>) {
chomp;
$count=0;
while ()
{
$count++;
if ($count <= $size
I am a new Perl user (not a student but research staff) and I'm trying to write a Perl program to manipulate some data files. I've used the split commands before to manipulate columns and rows but this is not working for my current need.
I have a program that outputs data in one continous column. For example if I have the program run two simulations (each containing 1000 data values), the program output is one continous column of 2000 data values.
What I am trying to do is have the Perl program generate 2 text files for each simulation each containing their respective column of 1000 data values.
The actual simulations I'm running contain over 500,000 data values each, so I need a perl script to handle it.
Many thanks for any help you can provide. The beginnings of the program I'm writing is below.
#!/usr/bin/perl -w
#Program reads GSLIB simulation output (continuous column of numbers) and writes individual
#output files for a user-defined number of GSLIB realizations
#
#GSLIB program outputs multiple realizations in a single continous column of data values.
#For example, if one realization contains 1000 data values and GSLIB is set to run 2 simulations,
#the output (*.txt file) will contain a continuous column of 2000 data values.
#What I'm trying to do is allow myself to enter the number of realizations (realiz) and the number
#of data values for each realization (size) and have the program output separate text files for
#each realization
@ARGV ++ 3 or die "Usage: extract.pl realiz size [in.file]\n";
$realiz = $ARGV[0];
$size = $ARGV[1];
$InFile = $ARGV[2];
# Open the input file (or die trying)
open(INPUT,"<$InFile") or die "Can't open file \"$file\".\n";
#loop through the file; start printing when
while (<INPUT>) {
chomp;
$count=0;
while ()
{
$count++;
if ($count <= $size