Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
To all the Monks here who might remember my past questions, I think I'm getting better... but yet again another question... This is my output file:
data data data data 7,843,391.58 xyz xzy xyz .... 12,224,675.68 abc ~~~ ~~~ .... 1,339,203.94 (more data) 21,407,271.2 (more data) 16,728,929.69 16,728,929.69
The following code is what I used; was taken from the Q and A section (thanks vroom) to insert commas.
sub addcommas{ my ($text)= $nocomma; $text=reverse $text; $text=~s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; $text=scalar reverse $text; return $text; }
My question/s is/are how can I: - align to the right the final column w/ the dollar amounts? (when printing out.. this is the end of a string print with other data left out for this example) or align the decimals? and - how to stop from dropping the end zero of the cents, where it's missing? This is my print statement how I got my final printout (where $comma is the returned variable caught from the above function):
for ($p = 0; $p < @a_table; $p++){ @a_print = split (/\t/, $a_table[$p]); $nocomma = $a_print[5] / 100; $comma = &addcommas(); print AUDIT "$a_print[0]\t$a_print[1]\t$read_time\t$a_print[3] +\t$comma\n"; } # end for loop
My final output is all correct, just the problems w/alignment and the loss of zero at end of cents... thanks for any/all help.

In reply to Decimal alignment and loss of zero at print? by Zo

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 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? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2022-01-22 00:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (60 votes). Check out past polls.

    Notices?