Why would this be a problem?
You can replace $f[4] with with int($f[4]) . " " x (length $f[4] - length int($f[4]));
Or you could use a regex instead of split...
Regex you could use:
Compact form:
s/(\d+(?:\.\d+)?)(?=(?:\s+\S+){4}$)/int ($1) . " " x (length($1) - length(int($1)))/eg;
Long way:
s/
( # Capture group $1
\d+ # Digits
(?: # Group (no capturing) (optional group)
\. # a dot
\d+ # Digits
)?
) # End capture $1
(?= # Open look-ahead
(?: # Group (no capturing)
\s+ # Whitespace
\S+ # Non-whitespace
)
{4} # Match previous group exactly four times
$ # Match end of line
)
/int ($1) . " " x (length($1) - length(int($1)))/egx;
Note: small version tested, big version untested
Update: forgot length, added a possible regex
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.