Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Printing large numbers with commas to show thousands groups.

by shmem (Chancellor)
on Dec 28, 2019 at 00:46 UTC ( #11110676=note: print w/replies, xml ) Need Help??


in reply to Re^2: Printing large numbers with commas to show thousands groups.
in thread Printing large numbers with commas to show thousands groups.

Hell, yes. There's always somebody who did it better than I could ever do. But! From the OP:
To modify existing code, just change your printf's to cprintf's and add apostrophe's to the formats as needed. Less work than wrapping each argument with a subroutine call and changing each format to %s. It also helps keep things clear and readable.

So, my attempt was to provide a solution without shelling out printf. And done, without having to pull in another package and introducing object syntax.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
  • Comment on Re^3: Printing large numbers with commas to show thousands groups.
  • Download Code

Replies are listed 'Best First'.
Re^4: Printing large numbers with commas to show thousands groups.
by Anonymous Monk on Dec 30, 2019 at 18:54 UTC

    ...And done, without having to pull in another package and introducing object syntax.

    ;) sub printf { ... hide object syntax }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11110676]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2020-05-26 18:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (150 votes). Check out past polls.

    Notices?