Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I agree with what the previous monks have said. I use it for tools and being a dba/admin, I have many tools where it is very useful for generating output. For ex:
sub print_logcon { my ($which,$f1,$f2,$f3,$f4) = @_; if ($which eq 'general') { print "$f1"; print LOG_FILE "$f1" or kill_and_clean_up( "Error printing to +$LOG_FILE: $!" ); } elsif ($which eq 'comparison') { my $f1_multi = $f1; format COMP_TOP = File version comparison Type File name Previous New ---------------------------------------------------------------------- +-------- . format COMP = @<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<< +<<<<<<<< $f4, $f1, $f2, $f3 ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $f1 . select(LOG_FILE); $^ = 'COMP_TOP'; $~ = 'COMP'; write LOG_FILE or kill_and_clean_up( "Error printing to $LOG_FILE: + $!" ); $f1 = $f1_multi; # format destroys the variable, so reassign it select(STDOUT); $^ = 'COMP_TOP'; $~ = 'COMP'; write STDOUT; } elsif ($which eq 'file_info') { my $f2_multi = $f2; format FILE_INFO_TOP = File Compilation Information Type File name Version ---------------------------------------------------------------------- +-------- . format FILE_INFO = @<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<< +<<<<<<<<< $f1, $f2, $f3 ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $f2 . select(LOG_FILE); $^ = 'FILE_INFO_TOP'; $~ = 'FILE_INFO'; write LOG_FILE or kill_and_clean_up( "Error printing to $LOG_FILE: + $!" ); $f2 = $f2_multi; # format destroys the variable, so reassign it select(STDOUT); $^ = 'FILE_INFO_TOP'; $~ = 'FILE_INFO'; write STDOUT; } }

In reply to You bet, and for the same thing as you.. by bcole23
in thread Do you use format and write? by pernod

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (10)
    As of 2019-10-16 11:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?