-
error in my perl code
I have the following code:
while (<INFILE> ) {
print OUTFILE;
}
The above code reads every line in my INFILE and writes it to the OUTFILE and works fine, but when I change it to the following it doesn't write anything to my OUTFILE ?
while (<INFILE> ) {
if ($_ eq "yes") {
print "$_";
print OUTFILE;
}
}
I only want to write those records to my outfile where the record ($_) = yes.
-
to print to the outfile you need to do this!
-
Actually the following lines should be equivalent:
Code:
print OUTFILE $_;
print OUTFILE;
This being Perl, if you wanted to write a file to std out:
Code:
while (<INFILE> ) {
print;
}