fellow monks,
A few months ago I submitted a piece a code and jeffa helped me out immensely by pointing me to
Perltidy. Stylistically, I know I have much room for improvement. One thing I'm hoping to improve upon is the presentation of data as produced by my scripts.
The following section of code presents a simple example.
open( WEBLOG, ">$log" );
print WEBLOG "====================\n";
foreach $string (@strings) {
chomp $string;
$string = "$string" . " HTTP/1.0\012\012";
my $sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $port,
Proto => $proto
);
print $sock "$string";
while (<$sock>) {
push @page, $_;
}
if ( $page[0] =~ m/404/ ) {
chomp $string;
print WEBLOG $string;
print WEBLOG "====================\n";
}
@page = ();
}
close(WEBLOG);
and this would produce the following output:
====================
GET /FOO HTTP/1.0
====================
GET /FOOBAR HTTP/1.0
====================
I am looking for a better way to present data such as this, e.g include a document title, page numbers, and multiple columns if appropriate. Currently, my formatting skills are limited to printing a series of characters to separate the output. Is there a better way? Any assistance will be greatly appreciated.
cheers, -semio
-
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.
|