Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Using (s)printf()

by AnomalousMonk (Chancellor)
on Aug 31, 2016 at 18:38 UTC ( #1170918=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using (s)printf()
in thread Using (s)printf()

Trailing whitespace can be a bit tricky. Maybe something like:

c:\@Work\Perl\monks>perl -wMstrict -le "for my $n (qw( 0.12345 -0.12345 123456.12 -123456.12 123456.12345 -123456.12345 )) { my ($left, $right) = (7, 5); my $s = sprintf qq{%${left}s.%-${right}s}, split m{[.]}xms, $n, 2; print qq{'$s'}; } " ' 0.12345' ' -0.12345' ' 123456.12 ' '-123456.12 ' ' 123456.12345' '-123456.12345'


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1170918]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-09-20 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (234 votes). Check out past polls.

    Notices?