use strict;
use warnings;
open(A,">Result.txt") or die "$!";
while(<DATA>) {
printf A "%-10s%-7s%-8s\n",split
}
close(A)
__DATA__
The Early Year
Five New Swine
Update: The default arguments to
split are sufficient: split $_ around whitespace.
The format string (first argument) to
printf is as follows:
% indicates the start of a format specifier, a value which follows the format string will be "plugged-in" and formatted into this position.
- means left justify the field
10 (or 7 or 8) is the
minimum field width. Shorter fields will be padded with spaces, longer will be displayed intact (data will not be lost).
s indicates the field is a string
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.