B
Brian
it may not be obvious from this novitiate perl code below, but i am
trying to add the lines of one file to the lines of another file to
create a third file. the lines in each file are semantically related,
and will always 'line up.'
use strict;
$ARGV[2] or die "Usage: perl stitch2files.pl [infile1] [infile2]
[outfile] - attaches all values from the list of equal values to ea
line of another list ";
my $infile1 = $ARGV[0];
my $infile2 = $ARGV[1];
my $outfile = $ARGV[2];
open INFILE1, $infile1 or die "Couldn't open input file: $infile1\n";
open INFILE2, $infile2 or die "Couldn't open input file: $infile2\n";
open OUTPUTFILE, ">$outfile" or die "Couldn't open output file:
$outfile\n";
my @data1 = <INFILE1>;
my @data2 = <INFILE2>;
close INFILE1;
close INFILE2;
my $sLine;
my $iLineCount = 0;
foreach $sLine (@data1)
{
my $sAddLine = "";
$iLineCount = $iLineCount + 1;
chomp($sLine);
$sAddLine = @data2[$iLineCount];
$sLine = $sLine . "," . $sAddLine;
printf $sLine;
print OUTPUTFILE $sLine;
}
close OUTPUTFILE;
exit(0);
problem is, i can't seem to address the individual items in the array
formed from the second file, from within a loop designed to process
each item in the first array (formed from the first file).
the error message, while understandable, seems unavoidable:
Use of uninitialized value in concatenation (.) or string at
stitch2files.pl lin
e 28.
any help would be appreciated
thanks
trying to add the lines of one file to the lines of another file to
create a third file. the lines in each file are semantically related,
and will always 'line up.'
use strict;
$ARGV[2] or die "Usage: perl stitch2files.pl [infile1] [infile2]
[outfile] - attaches all values from the list of equal values to ea
line of another list ";
my $infile1 = $ARGV[0];
my $infile2 = $ARGV[1];
my $outfile = $ARGV[2];
open INFILE1, $infile1 or die "Couldn't open input file: $infile1\n";
open INFILE2, $infile2 or die "Couldn't open input file: $infile2\n";
open OUTPUTFILE, ">$outfile" or die "Couldn't open output file:
$outfile\n";
my @data1 = <INFILE1>;
my @data2 = <INFILE2>;
close INFILE1;
close INFILE2;
my $sLine;
my $iLineCount = 0;
foreach $sLine (@data1)
{
my $sAddLine = "";
$iLineCount = $iLineCount + 1;
chomp($sLine);
$sAddLine = @data2[$iLineCount];
$sLine = $sLine . "," . $sAddLine;
printf $sLine;
print OUTPUTFILE $sLine;
}
close OUTPUTFILE;
exit(0);
problem is, i can't seem to address the individual items in the array
formed from the second file, from within a loop designed to process
each item in the first array (formed from the first file).
the error message, while understandable, seems unavoidable:
Use of uninitialized value in concatenation (.) or string at
stitch2files.pl lin
e 28.
any help would be appreciated
thanks