PerlNoob2005
Programmer
Hi all, I am new to the Perl language and am seeking guidance from you all
I am trying to write a fairly simple program, but I am running into difficulty due to my lack of tips and tricks of the language. I wish to read line by line from 2 input files (and one file may be larger or smaller than the other) and concatenate the strings located on these coinciding lines. If one input file is shorter than the other, then the concatenation is only to include the 1 line. Here is what I have so far:
#!/usr/bin/perl -w
unless(@ARGV)
{
print "usage: test.pl argument\n";
exit;
}
$file1 = $ARGV[0];
open (IN1, $file1);
$file2 = $ARGV[1];
open (IN2, $file2);
while ($DNA1 = <IN1> && $DNA2 = <IN2>)
{
$Concat = $DNA1.$DNA2;
print "HERE: $DNA1 $DNA2 \n Concatenation: $Concat \n";
}
$input3 = $ARGV[2];
print "$input3";
close IN1;
close IN2;
The above code gives me an error with the && operation. I am unsure as to how to continue reading from both input files at the same time, while one may be shorter than the other. Any tips or advice would be great. Thanks!
#!/usr/bin/perl -w
unless(@ARGV)
{
print "usage: test.pl argument\n";
exit;
}
$file1 = $ARGV[0];
open (IN1, $file1);
$file2 = $ARGV[1];
open (IN2, $file2);
while ($DNA1 = <IN1> && $DNA2 = <IN2>)
{
$Concat = $DNA1.$DNA2;
print "HERE: $DNA1 $DNA2 \n Concatenation: $Concat \n";
}
$input3 = $ARGV[2];
print "$input3";
close IN1;
close IN2;
The above code gives me an error with the && operation. I am unsure as to how to continue reading from both input files at the same time, while one may be shorter than the other. Any tips or advice would be great. Thanks!