(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.)


In reply to Re^3: Comparing files by graff
in thread Comparing files by dannyp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.