I have the following code:
$printline="O*N%1d5TG%5d ,CLS=%.8s,XXX,BAT=, + \n"; $dest_mailbox=shift(@ARGV); $file=shift(@ARGV); $message_class=shift(@ARGV); # Set up a temp file as a holding file for valid lines $rand = int(rand(10000)); $tempfile="$file" . "$rand"; print "!Creating temp file: $tempfile!\n"; while (-f $tempfile) { $rand = int(rand(10000)); $tempfile="$file" . "$rand"; } # # Open the input file and temporary file # open (FILE, "$file") or &exit_with_error("!Error opening file for read +: $file!\n"); open (TEMP, ">>$tempfile") or &exit_with_error("!Error opening file fo +r write: $tempfile!\n"); # $total_lines=0; $hort=0; ** Prints to temp file the header record ** printf TEMP $printline,$hort, $dest_mailbox, $message_class; ** Prints to temp file the data from another file ** while (<FILE>) { $total_lines++; chomp($_); print TEMP "$_\n"; $data_lines++; } } ** Prints to TEMP file the trailer record. $hort=9; printf TEMP $printline, $hort, $dest_mailbox, $message_class;

The whole idea behind this code is to take a file that has data records and insert header and trailer records. The data moves over just fine, but the header and trailer records have a small square box which should be a new line character but is not. The file needs to have a the data on the next line. For some reason the temp file does not like the \n on the header and trailer record.


In reply to My Script is saving a New Line Character as an Unreadable character. by kramdeav

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.