|
-
Oct 16th, 2001, 11:03 AM
#1
Thread Starter
Addicted Member
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.
-
Oct 17th, 2001, 06:02 AM
#2
Hyperactive Member
to print to the outfile you need to do this!
-
Oct 17th, 2001, 07:05 AM
#3
Black Cat
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;
}
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|