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;
}
}
-
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.
|