I have a problem with 'format'. If you have a Close for the filehandle before a re-open of the same filehandle into a different filestring, the headings don't work. The file test2 doesn't have the headings.

#!/usr/local/bin/perl use strict; use warnings; open(DM,">c:/test1.txt"); my ($r_fran,$r_par,$r_con,$r_pcode,$r_ser,$r_add1,$r_add2,$r_email,$r_ +acc,$r_name) =("aaa","123","321","bs11","o","14 street","town",'sp@here',"00123","s +cott"); my $edate=localtime(time); format DM_TOP = High Value Report for depot @<<<< on @<<<<<< +<<<<<<<<<<<<<< page @## ,$r_fran, $edate +, $% Parcel Number Account Consignment Name & Address + Postcode Srvc ------------- ------- ----------- -------------- + -------- ---- . format DM = @<<<<<<<<<<<< @<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<< + @<<<<<<<< @<<<< $r_par, $r_acc, $r_con, $r_name, + $r_pcode, $r_ser @<<<<<<<<<<<<<<<<<<<< $r_add1 @<<<<<<<<<<<<<<<<<<<< $r_add2 Driver Signature Superviser Signature ----------------------------------- ---------------------------- +------- Driver Signature Superviser Signature ----------------------------------- ---------------------------- +------- . write DM; close DM; open(DM,">c:/test2.txt"); ($r_fran,$r_par,$r_con,$r_pcode,$r_ser,$r_add1,$r_add2,$r_email,$r_acc +,$r_name) =("zzz","123","321","bs11","o","14 street","town",'sp@here',"00123","s +cott"); $edate=localtime(time); write DM; close DM;

2006-03-24 Retitled by Arunbear, as per Monastery guidelines
Original title: 'Format'


In reply to Format headers and filehandles by bitman

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.