Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-25 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found