(1) When you post, use <code> to mark the beginning of source code, and </code> to mark the end. Always. (In fact, use it when posting data samples, command lines and anything else where spacing or brackets are important.)
(2) Read the man page description for the "print" function (do "perldoc -f print", or if you're using the docs in html form, browse the "perlfunc" page for the "print" function).
(3) You seem to think that the angle bracket should be used with "print", as if doing redirection (or maybe you learned C++ first?). Anyway, printing to a file handle works like this:
print OUT "string to be printed to outputfile\n";
# or like this:
$outstring = "string to be printed\n";
print OUT $outstring;
Really simple. The only thing that's a little strange is that you don't ever put a comma between the file handle and the stuff to be printed to it.
Update -- one other thing (call it "4") -- just in case you're not clear on this: If you are doing iterations in any sort of loop, and want to print to a file handle on each iteration, be sure to open the file before going into the loop, and close it after the loop. Do NOT open, write and close the file on every iteration. (The format of your question made me worry that this might not be clear.) |